summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go33
1 files changed, 11 insertions, 22 deletions
diff --git a/main.go b/main.go
index 9729e87..3e63b63 100644
--- a/main.go
+++ b/main.go
@@ -11,20 +11,15 @@ import (
lru "github.com/hashicorp/golang-lru"
)
-var (
- Version string
- Build string
-)
-
const maxLen = 450
-type Notify struct {
+type notify struct {
conn *irc.Conn
target string
}
-func NewNotify(conn *irc.Conn, target string) *Notify {
- return &Notify{conn: conn, target: target}
+func newNotify(conn *irc.Conn, target string) *notify {
+ return &notify{conn: conn, target: target}
}
func limit(n int, s string) string {
@@ -35,7 +30,7 @@ func limit(n int, s string) string {
return string(r)
}
-func (n *Notify) Write(p []byte) (int, error) {
+func (n *notify) Write(p []byte) (int, error) {
s := limit(maxLen, string(p))
log.Println("send", s)
n.conn.Notice(n.target, s)
@@ -70,7 +65,7 @@ func privmsg(room string) irc.HandlerFunc {
fixed, err := re(tofix.(string), t[1:], global)
if err == nil && fixed != tofix {
log.Println("regexp", t)
- fmt.Fprintf(NewNotify(conn, line.Target()), "%v meant to say: %s", line.Nick, fixed)
+ fmt.Fprintf(newNotify(conn, line.Target()), "%v meant to say: %s", line.Nick, fixed)
return
}
@@ -88,7 +83,7 @@ func privmsg(room string) irc.HandlerFunc {
titles.Add(v, title)
}
if title != "" {
- w := NewNotify(conn, line.Target())
+ w := newNotify(conn, line.Target())
if ok {
fmt.Fprintf(w, "Title: %v (cached)", title)
} else {
@@ -103,19 +98,13 @@ func privmsg(room string) irc.HandlerFunc {
func main() {
var (
- node = flag.String("node", "irc.freenode.org", "IRC server")
- notls = flag.Bool("notls", false, "disable TLS")
- room = flag.String("room", "#lor", "IRC channel")
- name = flag.String("name", "dim13", "bots name")
- version = flag.Bool("version", false, "display version and exit")
+ node = flag.String("node", "irc.freenode.org", "IRC server")
+ notls = flag.Bool("notls", false, "disable TLS")
+ room = flag.String("room", "#lor", "IRC channel")
+ name = flag.String("name", "dim13", "bots name")
)
flag.Parse()
- if *version {
- log.Printf("Version: %v, Build: %v", Version, Build)
- return
- }
-
conf := irc.NewConfig(*name)
conf.Server = *node
if !*notls {
@@ -132,7 +121,7 @@ func main() {
conn.HandleFunc(irc.CONNECTED, func(conn *irc.Conn, _ *irc.Line) {
conn.Join(*room)
- Watch(NewNotify(conn, *room), Feeds)
+ watch(newNotify(conn, *room), feeds)
})
conn.HandleBG(irc.PRIVMSG, privmsg(*room))