From 2b1c9889e58cf11fd9df941924c4f8372c41550b Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 25 Oct 2018 01:04:35 +0100 Subject: misc improvements added self reference, allowing the bot to accrue currency messed about with some messages (removed swears, changed 'schlorped', etc) improved send output regular wattery to make 'wat' interesting --- wat/bot.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'wat/bot.go') diff --git a/wat/bot.go b/wat/bot.go index c2a1d14..dbb16b2 100644 --- a/wat/bot.go +++ b/wat/bot.go @@ -35,7 +35,6 @@ func CleanNick(nick string) string { } func (w *WatBot) HandleIrcMsg(c *irc.Client, m *irc.Message) { - fmt.Println(m) switch cmd := m.Command; cmd { case "PING": w.write("PONG", m.Params[0]) @@ -64,11 +63,12 @@ func (w *WatBot) Msg(m *irc.Message) { return } + // make sure there's actually some text to process if len(m.Params[1]) == 0 { return } - + // fieldsfunc allows you to obtain rune separated fields/args args := strings.FieldsFunc(m.Params[1], func(c rune) bool {return c == ' '}) if len(args) == 0 { @@ -76,9 +76,13 @@ func (w *WatBot) Msg(m *irc.Message) { } if w.Admin(m) { - // Do a special admin command and return, or continue + // allow impersonation of the robot from anywhere if args[0] == "imp" && len(args) > 2 { - w.write(args[1], args[2:]...) + if args[1] == "PRIVMSG" { + w.write(args[1], strings.Join(args[2:], " ")) + } else { + w.write(args[1], args[2:]...) + } return } } @@ -108,7 +112,7 @@ func (w *WatBot) Run() { defer w.conn.Close() err := w.client.Run() if err != nil { - fmt.Println(err.Error()) + fmt.Println("Error returned while running client: " + err.Error()) } } -- cgit v1.2.3