summaryrefslogtreecommitdiff
path: root/rfc.go
diff options
context:
space:
mode:
Diffstat (limited to 'rfc.go')
-rw-r--r--rfc.go22
1 files changed, 5 insertions, 17 deletions
diff --git a/rfc.go b/rfc.go
index 69c0b7e..a072cc1 100644
--- a/rfc.go
+++ b/rfc.go
@@ -3,7 +3,6 @@ package main
import (
"fmt"
"log"
- "strconv"
"strings"
"dim13.org/rfc"
@@ -12,20 +11,14 @@ import (
var rfcMap = make(map[int]rfc.Entry)
-type RFC struct{ Command }
-
-func (_ RFC) Timeout() bool { return false }
-func (_ RFC) WithArgs(n int) bool { return n == 2 }
-func (_ RFC) Handle(conn *irc.Conn, line *irc.Line) {
- if q := strings.Fields(line.Text()); len(q) == 2 {
- if id, err := strconv.Atoi(q[1]); err != nil {
- conn.Privmsg(line.Target(), err.Error())
- } else {
+func ExtractRFC(conn *irc.Conn, line *irc.Line) {
+ for _, v := range strings.Fields(line.Text()) {
+ var id int
+ w := strings.ToUpper(v)
+ if _, err := fmt.Sscanf(w, "RFC%d", &id); err == nil {
if entry, ok := rfcMap[id]; ok {
s := fmt.Sprint(entry)
conn.Privmsg(line.Target(), s)
- } else {
- conn.Privmsg(line.Target(), "not found")
}
}
}
@@ -44,9 +37,4 @@ func init() {
id := e.ID()
rfcMap[id] = e
}
- Register("rfc", &RFC{
- Command{
- Help: "Perform RFC lookup",
- },
- })
}