original BYbot
This commit is contained in:
parent
2ffb956f57
commit
7d9244941f
110
bots/bybot/bybot.go
Normal file
110
bots/bybot/bybot.go
Normal file
@ -0,0 +1,110 @@
|
||||
package bybot
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"math/rand"
|
||||
"regexp"
|
||||
"time"
|
||||
|
||||
irc "github.com/fluffle/goirc/client"
|
||||
)
|
||||
|
||||
const name = "BYbot"
|
||||
|
||||
type BY struct {
|
||||
quotes []string
|
||||
}
|
||||
|
||||
func (by *BY) Random() string {
|
||||
if len(by.quotes) == 0 {
|
||||
return ""
|
||||
}
|
||||
return by.quotes[rand.Intn(len(by.quotes))]
|
||||
}
|
||||
|
||||
func (by *BY) spew(conn *irc.Conn, channel string) {
|
||||
for {
|
||||
delay := time.Duration(2+rand.Intn(24)) * time.Hour
|
||||
log.Printf("sleeping: %+v", delay)
|
||||
time.Sleep(delay)
|
||||
conn.Privmsg(channel, by.Random())
|
||||
}
|
||||
}
|
||||
|
||||
func Register(host, channel string, done chan<- bool) {
|
||||
var p *regexp.Regexp
|
||||
by := BY{quotes}
|
||||
|
||||
c := irc.SimpleClient(name, name)
|
||||
c.EnableStateTracking()
|
||||
|
||||
c.HandleFunc(
|
||||
irc.CONNECTED,
|
||||
func(conn *irc.Conn, line *irc.Line) {
|
||||
conn.Join(channel)
|
||||
var err error
|
||||
p, err = regexp.Compile(`\b` + conn.Me().Nick + `\b`)
|
||||
if err != nil {
|
||||
log.Printf("%+v", err)
|
||||
}
|
||||
go by.spew(conn, channel)
|
||||
},
|
||||
)
|
||||
c.HandleFunc(
|
||||
irc.DISCONNECTED,
|
||||
func(conn *irc.Conn, line *irc.Line) {
|
||||
done <- true
|
||||
},
|
||||
)
|
||||
c.HandleFunc(
|
||||
irc.PRIVMSG,
|
||||
func(conn *irc.Conn, line *irc.Line) {
|
||||
if p.MatchString(line.Text()) {
|
||||
log.Printf("addressed me: %v", line.Text())
|
||||
conn.Privmsg(channel, by.Random())
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
if err := c.ConnectTo(host); err != nil {
|
||||
fmt.Printf("Connection error: %s\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
var quotes []string = []string{
|
||||
"♬♬ God changed his mind about black people (black people!!) ♬♬",
|
||||
|
||||
"Wife! Bring me a wife!!",
|
||||
"Your own blood must atone for some sins",
|
||||
"You must confess Joseph Smith as a prophet of God in order to be saved.",
|
||||
"My discourses are as good as Scripture!",
|
||||
"I say now, when [my discourses] are copied and approved by me they are as good Scripture as is couched in this Bible!",
|
||||
|
||||
"I have never given any counsel that was wrong.",
|
||||
|
||||
"I know just as well what to teach this people and just what to say to them and what to do in order to bring them into the celestial kingdom.",
|
||||
"I have never yet preached a sermon and sent it out to the children of men, that they may not call Scripture",
|
||||
" Let me have the privilege of correcting a sermon, and it is as good Scripture as they deserve.",
|
||||
"[Because of me] The people have the oracles of God continually.",
|
||||
|
||||
"I was a collosal asshole.",
|
||||
"[mumble mumble mumble] negros [mumble mumble mumble]",
|
||||
|
||||
"You are damned if you deny polygamy!",
|
||||
"Now if any of you will deny the plurality of wives, and continue to do so, I promise that you will be damned.",
|
||||
"The only men who become Gods, even the Sons of God, are those who enter into polygamy,",
|
||||
"No man or woman in this dispensation will ever enter into the celestial kingdom of God without the consent of Joseph Smith",
|
||||
"The success which has attended me in my presidency is owing to the blessings and mercy of the Almighty.",
|
||||
"Now hear it, O inhabitants of the earth, Jew and Gentile, Saint and sinner!",
|
||||
"This is the place [... they can't prosecute polygamy here].",
|
||||
"It is enough. This is the right place, drive on.",
|
||||
|
||||
"You see some classes of the human family that are black, uncouth, uncomely, disagreeable and low in their habits, wild, and seemingly deprived of nearly all the blessings of the intelligence that is generally bestowed upon mankind",
|
||||
"Cain slew his brother. Cain might have been killed, and that would have put a termination to that line of human beings. This was not to be, and the Lord put a mark upon him, which is the flat nose and black skin",
|
||||
"We knew that the children of Ham were to be the \"servant of servants,\"",
|
||||
"\"servant of servants\" ... looks weird when you type it out",
|
||||
|
||||
"Shall I tell you the law of God in regard to the African race?",
|
||||
"If the white man who belongs to the chosen seed mixes his blood with the seed of Cain, the penalty, under the law of God, is death on the spot. This will always be so",
|
||||
}
|
24
main.go
Normal file
24
main.go
Normal file
@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"log"
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"mcquay.me/exmo/bots/bybot"
|
||||
)
|
||||
|
||||
var host *string = flag.String("host", "localhost:6668", "irc server hostname")
|
||||
var channel *string = flag.String("channel", "#exmormon", "irc channel")
|
||||
|
||||
func main() {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
flag.Parse()
|
||||
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
|
||||
|
||||
done := make(chan bool)
|
||||
|
||||
bybot.Register(*host, *channel, done)
|
||||
<-done
|
||||
}
|
Loading…
Reference in New Issue
Block a user