diff options
author | alex | 2018-10-25 01:04:35 +0100 |
---|---|---|
committer | alex | 2018-10-25 01:04:35 +0100 |
commit | 2b1c9889e58cf11fd9df941924c4f8372c41550b (patch) | |
tree | 15aa3794b9b850241293cdb04fb1c1dc7cdb482e /wat/bot.go | |
parent | 30d5e6f07674b316bf5542d2d6fdb8654e8bda39 (diff) | |
download | watbot-2b1c9889e58cf11fd9df941924c4f8372c41550b.tar.gz watbot-2b1c9889e58cf11fd9df941924c4f8372c41550b.tar.bz2 watbot-2b1c9889e58cf11fd9df941924c4f8372c41550b.zip |
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
Diffstat (limited to 'wat/bot.go')
-rw-r--r-- | wat/bot.go | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -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()) } } |