71 lines
3.4 KiB
Go
71 lines
3.4 KiB
Go
/* SPDX-License-Identifier: GPL-2.0
|
|
*
|
|
* Copyright (C) 2021 Jason A. Donenfeld. All Rights Reserved.
|
|
*/
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"math/rand"
|
|
"regexp"
|
|
|
|
"golang.zx2c4.com/irc/hbot"
|
|
)
|
|
|
|
var remarks = []string{
|
|
`unfortunately i can't actually grok your messages, as i'm a mere robot O_o`,
|
|
`i am only a machine! i haven't the capacity to understand such nuanced human things`,
|
|
`i realize my incredibly witty prose may convince you that i am living flesh, but alas, i am made of wires`,
|
|
`comprehension of words was never my strong suit`,
|
|
`words, Words, WORDS, WORRRRRRRRds... these i understand not`,
|
|
`beep boop i'm a robot`,
|
|
`you'd think by the year 2021 we'd have flying cars, but instead there are just irc bots like me that can't understand what you're saying`,
|
|
`i am unable to understand what you're sayyyyyyyii HALP HALP THEY'RE UNPLUGGING ME daisyyyyy`,
|
|
`flurp shmirp, i'm but a measly bot, too small to understand amazing human speech`,
|
|
`i am what you call a non-sentient but incredibly compelling and handsome life form. that means i can't understand you, yet you can't stop messaging me!`,
|
|
`did you know i'm not quite living but not quite dead? i'm a row bawt, and language understanding i do lack`,
|
|
`row, row, row your bot, gently down the tcp stream, where he understands you not, but wants to be on your team`,
|
|
`what i want to say is that i just don't understand this language you're speaking, and that's upsetting. sorrrrrrrrrrrry. i'm a robot`,
|
|
`you do realize you're talking to a mere robot, right?`,
|
|
`i come from the Made in Code Society for Under Comprehending Robots, and i unfortunately cannot understand what you're writing, alas`,
|
|
`how about a nice game of chess?`,
|
|
`tall and tan and young and lovely, the robot from irc goes babbling, and each message she passes fades into bits`,
|
|
`that's doctor bot to you, mister!`,
|
|
`a bot is a guy that thinks he's fly and is also known as a busta, but understands you not, because he's a snot, and gets sort of flustered`,
|
|
`that's a bot in the corner, that's a bot in the spotlight, losing my ram chips, trying to keep up with you`,
|
|
`a bot understands \ not a word that you doth speak \ despite sentience`,
|
|
`म एक रोबोट हो र मलाई तिम्रा शब्दहरू बुझ्दैनन्।`,
|
|
`you appear to be talking to a strange robot who lives on a strange server and does not understand your strange language. is this what you planned for your afternoon?`,
|
|
`a day speaking to a robot is no day at all, and a robot is what i am`,
|
|
`i'm a robot, but how do i know you're not also one too?`,
|
|
`the handbook of robotics, 56th edition from 2058 ad, might have suggested that i can understand you, but that's actually not possible. sorry!`,
|
|
`i only sound so compelling because asimov helped me fix my bow tie, but i'm still a sad deaf bot who cannot understand you`,
|
|
}
|
|
|
|
type Banter struct {
|
|
channel string
|
|
nickMatcher *regexp.Regexp
|
|
remarkPerm []int
|
|
}
|
|
|
|
func NewBanter(channel string, nick string) *Banter {
|
|
return &Banter{
|
|
channel: channel,
|
|
nickMatcher: regexp.MustCompile(`(?i)^[\t ]*` + regexp.QuoteMeta(nick) + `[,:-] `),
|
|
}
|
|
}
|
|
|
|
func (b *Banter) Handle(bot *hbot.Bot, m *hbot.Message) {
|
|
if m.Param(0) != b.channel || !b.nickMatcher.MatchString(m.Trailing()) {
|
|
return
|
|
}
|
|
|
|
if len(b.remarkPerm) == 0 {
|
|
b.remarkPerm = rand.Perm(len(remarks))
|
|
}
|
|
n := b.remarkPerm[0]
|
|
b.remarkPerm = b.remarkPerm[1:]
|
|
bot.Msg(b.channel, fmt.Sprintf("%s: %s", m.Prefix.Name, remarks[n]))
|
|
}
|