diff --git a/src/boddle.db b/src/boddle.db index ab1582695156c8bb71bc67a2ada26bb4e1365965..c68bb08cdb3af69e5f08e528e0c83da0c4d58b6a 100644 Binary files a/src/boddle.db and b/src/boddle.db differ diff --git a/src/bot.go b/src/bot.go index e7216a920b23bad5b19db0031b0cb505dd478789..4ff1568af8dfb8c1779c6da1b3cae07945b2b2ca 100644 --- a/src/bot.go +++ b/src/bot.go @@ -25,6 +25,10 @@ type bot struct { channel1 string channel2 string channel3 string + channel4 string + channel5 string + channel6 string + channel7 string port int server string conn net.Conn @@ -58,7 +62,7 @@ func scanline_privmsg (msg string) irc_msg { func parsemsg(line string, foo bot) bool { ircmsg := scanline_privmsg (line) - functs := []string{"help", "info", "meow", "jokes", "gra", "idb", "flirt", "add jokes", "add flirt", "geh schlafen", "deutsch"} + functs := []string{"help", "info", "meow", "jokes", "idb", "flirt", "add jokes", "add flirt", "geh schlafen", "deutsch"} blobs := []string{"frauen", "GRa", "egalwie", "scherzfragen", "sterben", "deinemudder", "gulasch", "flach", "maenner", "telefon"} @@ -75,7 +79,27 @@ func parsemsg(line string, foo bot) bool { "zinn_des_lebens": true, } - if strings.HasPrefix(ircmsg.msg, "+help") { +/* + if strings.HasPrefix(ircmsg.msg, ">") { + if strings.Compare(ircmsg.author, "cody") == 0 { + sendmsg(foo.conn, ircmsg.channel, "klein cody möchte bitte von mama mute aus dem bällebad abgeholt werden!") + return true + } else if strings.Compare(ircmsg.author, "mute") == 0 { + bloederspruch := []string{"awwwww mal wieder auf der Suche nach Liebe?", + "Hallo kleiner :)", + "Du suchst was lustiges oder? hamma ned", + "Kääääääääääääääääääsebrot!", + "Ja, das sind nur endlich viele dumme Sprüche...", + "lalallalaallaalaaaaaa", + "Bist du ein Blobfisch?", + "Erst haten und dann doch nutzen...."} + + sendmsg(foo.conn, ircmsg.channel, bloederspruch[rand.Int()%len(bloederspruch)]) + } + } +*/ + + if strings.HasPrefix(ircmsg.msg, ">help") { // help input := strings.Split(ircmsg.msg, " ") if len(input) == 2 { @@ -99,39 +123,37 @@ func parsemsg(line string, foo bot) bool { case "meow": helpmsg = "the bot changes to a not really helpful cat like every cat but is not fluffy during that phase so this function is kinda useless?" case "jokes": - helpmsg = fmt.Sprintf("call with +jokes for a random category, call with one or more categories from %s to receive a joke selected from those categories", fmt.Sprintf(strings.Join(blobs, ", "))) - case "gra": - helpmsg = "print famous citations from a small group of GRa-ndiose students" + helpmsg = fmt.Sprintf("call with >jokes for a random category, call with one or more categories from %s to receive a joke selected from those categories", fmt.Sprintf(strings.Join(blobs, ", "))) case "idb": - helpmsg = "get your personalized database-related nickname by calling +idb or get one for your friend with +idb <name>" + helpmsg = "get your personalized database-related nickname by calling >idb or get one for your friend with >idb <name>" case "flirt": - helpmsg = "get flirt messages with +flirt or flirt with your best friend using +flirt <your love>" + helpmsg = "get flirt messages with >flirt or flirt with your best friend using >flirt <your love>" case "add jokes": - helpmsg = "type +add jokes for more information" + helpmsg = "type >add jokes for more information" case "add flirt": - helpmsg = "add your best pick up line using +add flirt <pickup line>" + helpmsg = "add your best pick up line using >add flirt <pickup line>" case "geh schlafen": helpmsg = "send the bot to sleep until the next reconnect" case "deutsch": - helpmsg = "get a personalized nickname, enriched by some mysterious german word, by calling +deutsch or get one for your friend with +deutsch <name>" + helpmsg = "get a personalized nickname, enriched by some mysterious german word, by calling >deutsch or get one for your friend with >deutsch <name>" } - sendmsg(foo.conn, ircmsg.channel, fmt.Sprintf("+%s: %s", req, helpmsg)) + sendmsg(foo.conn, ircmsg.channel, fmt.Sprintf(">%s: %s", req, helpmsg)) } } else if len(input) > 2 { sendmsg(foo.conn, ircmsg.channel, fmt.Sprintf("Please choose only one function for help: %s", fmt.Sprintf(strings.Join(functs, ", ")))) } else { sendmsg(foo.conn, ircmsg.channel, "Segmentation fault") - sendmsg(foo.conn, ircmsg.channel, fmt.Sprintf("I haz functs: %s, call +help <func> for more information on da function :)", + sendmsg(foo.conn, ircmsg.channel, fmt.Sprintf("I haz functs: %s, call >help <func> for more information on da function :)", fmt.Sprintf(strings.Join(functs, ", ")))) } - } else if strings.Compare(ircmsg.msg, "+info") == 0 { + } else if strings.Compare(ircmsg.msg, ">info") == 0 { // info sendmsg(foo.conn, ircmsg.channel, "created in golang with love, cats and tears >:)") - } else if strings.Compare(ircmsg.msg, "+meow") == 0 { + } else if strings.Compare(ircmsg.msg, ">meow") == 0 { // meow sendmsg(foo.conn, ircmsg.channel, meow[rand.Int()%len(meow)]) - } else if strings.HasPrefix(ircmsg.msg, "+jokes") { + } else if strings.HasPrefix(ircmsg.msg, ">jokes") { // jokes var jokes []string @@ -152,9 +174,9 @@ func parsemsg(line string, foo bot) bool { var tasks string if (len(jokes) == 0) { - tasks = fmt.Sprintf("select e.line, c.name from jokes e join category c on c.id = e.category") + tasks = fmt.Sprintf("select e.line, c.name from jokes e join category c on c.id = e.category ORDER BY RANDOM() LIMIT 1") } else { - tasks = fmt.Sprintf("select e.line from jokes e join category c on c.id = e.category where c.name = '%s'", fmt.Sprintf(strings.Join(jokes, "' or c.name = '"))) + tasks = fmt.Sprintf("select e.line from jokes e join category c on c.id = e.category where c.name = '%s' ORDER BY RANDOM() LIMIT 1", fmt.Sprintf(strings.Join(jokes, "' or c.name = '"))) } rows, err := db.Query(tasks) @@ -162,35 +184,34 @@ func parsemsg(line string, foo bot) bool { panic(err) return true } - var joke []string - var cats []string + var joke string + var cats string for rows.Next() { if (len(jokes) == 0) { var curr string var catc string rows.Scan(&curr, &catc) - joke = append(joke, curr) - cats = append(cats, catc) + joke = curr + cats = catc } else { var curr string rows.Scan(&curr) - print(curr) - joke = append(joke, curr) + joke = curr } } rows.Close() + if (len(joke) == 0) { sendmsg(foo.conn, ircmsg.channel, "There are no jokes bitch. Or this programmer sucks...") } else { if (len(jokes) == 0) { - tmp := rand.Int()%len(joke) - sendmsg(foo.conn, ircmsg.channel, fmt.Sprintf("from category %s: %s", cats[tmp], joke[tmp])) + sendmsg(foo.conn, ircmsg.channel, fmt.Sprintf("from category %s: %s", cats, joke)) } else { - sendmsg(foo.conn, ircmsg.channel, joke[rand.Int()%len(joke)]) + sendmsg(foo.conn, ircmsg.channel, joke) } } - } else if strings.HasPrefix(ircmsg.msg, "+add jokes") { + } else if strings.HasPrefix(ircmsg.msg, ">add jokes") { if ! jokeusers[ircmsg.author] { sendmsg(foo.conn, ircmsg.channel, "lol bitch get funnier") // return true @@ -254,13 +275,19 @@ func parsemsg(line string, foo bot) bool { return true } sendmsg(foo.conn, ircmsg.channel, "i guess that worked") - } else if strings.HasPrefix(ircmsg.msg, "+flirt") { + } else if strings.HasPrefix(ircmsg.msg, ">flirt preisi") { + sendmsg(foo.conn, ircmsg.channel, "~PREISI IST SEXY~ - deine Verehrer von dem neuen Ecksofa.") + } else if strings.HasPrefix(ircmsg.msg, ">flirt") || strings.Contains(ircmsg.msg, " liebe ") || strings.Contains(ircmsg.msg, " Liebe ") || strings.Contains(ircmsg.msg, " love ") || strings.Contains(ircmsg.msg, " Love ") { // flirt var ppl []string - for _, v := range strings.Split(ircmsg.msg, " ") { - if ! strings.HasPrefix(v, "+flirt") { - ppl = append(ppl, v) + if strings.HasPrefix(ircmsg.msg, ">flirt") { + for _, v := range strings.Split(ircmsg.msg, " ") { + if ! strings.HasPrefix(v, ">flirt") { + ppl = append(ppl, v) + } } + } else { + ppl = append(ppl,ircmsg.author) } db, err := sql.Open("sqlite3", "./boddle.db") @@ -269,26 +296,28 @@ func parsemsg(line string, foo bot) bool { return true } - rows, err := db.Query("select e.flirt from flirt e") + rows, err := db.Query("select e.flirt from flirt e ORDER BY RANDOM() LIMIT 1") if err != nil { panic(err) return true } - var flirt []string + var flirt string for rows.Next() { var curr string rows.Scan(&curr) - flirt = append(flirt, curr) + flirt = curr } rows.Close() if (len(ppl) == 0) { - sendmsg(foo.conn, ircmsg.channel, flirt[rand.Int()%len(flirt)]) + sendmsg(foo.conn, ircmsg.channel, flirt) return true } else { - sendmsg(foo.conn, ircmsg.channel, fmt.Sprintf("%s, %s <3", flirt[rand.Int()%len(flirt)], fmt.Sprintf(strings.Join(ppl, ", ")))) + sendmsg(foo.conn, ircmsg.channel, fmt.Sprintf("%s, %s <3", flirt, fmt.Sprintf(strings.Join(ppl, ", ")))) } - } else if strings.HasPrefix(ircmsg.msg, "+add flirt") { + } else if strings.HasPrefix(ircmsg.msg, "horscchtey: fix") { + sendmsg(foo.conn, ircmsg.channel, "Hat mich denn hier niemand so lieb, wie ich bin? :(") + } else if strings.HasPrefix(ircmsg.msg, ">add flirt") { if ! jokeusers[ircmsg.author] { sendmsg(foo.conn, ircmsg.channel, "ur a cum-puter sciene student, learn how to flirt!") } @@ -324,15 +353,11 @@ func parsemsg(line string, foo bot) bool { return true } sendmsg(foo.conn, ircmsg.channel, "congrats, no woman will ever like you") - } else if strings.HasPrefix(ircmsg.msg, "+idb") { - // flirt - t := strings.SplitN(ircmsg.msg, "idb ", 2) + } else if strings.HasPrefix(ircmsg.msg, ">idb") { + // idb + t := strings.SplitN(ircmsg.msg, " ", 2) var name string - if len(t) > 2 { - sendmsg(foo.conn, ircmsg.channel, fmt.Sprintf("usage: deutsch <ONE name here>")) - return true - } - if len(t[1]) < 2 { + if len(t) < 2 { name = ircmsg.author } else { name = t[1] @@ -371,15 +396,11 @@ func parsemsg(line string, foo bot) bool { rows.Close() sendmsg(foo.conn, ircmsg.channel, fmt.Sprintf("%s-%s", idb[rand.Int()%len(idb)], name)) - } else if strings.HasPrefix(ircmsg.msg, "+deutsch") { - // flirt - t := strings.SplitN(ircmsg.msg, "deutsch ", 2) + } else if strings.HasPrefix(ircmsg.msg, ">deutsch") { + // deutsch + t := strings.SplitN(ircmsg.msg, " ", 2) var name string - if len(t) > 2 { - sendmsg(foo.conn, ircmsg.channel, fmt.Sprintf("usage: deutsch <ONE name here>")) - return true - } - if len(t[1]) < 2 { + if len(t) < 2 { name = ircmsg.author } else { name = t[1] @@ -418,7 +439,7 @@ func parsemsg(line string, foo bot) bool { rows.Close() sendmsg(foo.conn, ircmsg.channel, fmt.Sprintf("%s-%s", idb[rand.Int()%len(idb)], name)) - } else if strings.Compare(ircmsg.msg, "+geh schlafen") == 0 { + } else if strings.Compare(ircmsg.msg, ">geh schlafen") == 0 { if strings.Compare(ircmsg.author, "horscchtey") == 0 || strings.Compare(ircmsg.author, "rincewind") == 0 { sendmsg(foo.conn, ircmsg.channel, "はい、マスター") @@ -426,9 +447,9 @@ func parsemsg(line string, foo bot) bool { } else { sendmsg(foo.conn, ircmsg.channel, "lol nope") } - } else if strings.HasPrefix(ircmsg.msg, "+") { + } else if strings.HasPrefix(ircmsg.msg, ">") { sorrybro := "Sorry bro I did not understand that..." - helpingoffer := "you can type +help for more information on my skills" + helpingoffer := "you can type >help for more information on my skills" sendmsg(foo.conn, ircmsg.channel, fmt.Sprintf("%s %s", sorrybro, helpingoffer)) } return true @@ -491,6 +512,7 @@ func connect(boddle bot) <-chan []byte { fmt.Fprintf(boddle.conn, "JOIN %s\r\n", boddle.channel1) fmt.Fprintf(boddle.conn, "JOIN %s\r\n", boddle.channel2) fmt.Fprintf(boddle.conn, "JOIN %s\r\n", boddle.channel3) + fmt.Fprintf(boddle.conn, "JOIN %s\r\n", boddle.channel4) return listenToIRC(boddle) } @@ -503,7 +525,8 @@ func main() { channel0: "#faui2k16", channel1: "#fau", channel2: "#faui2k18", - channel3: "#faui2k19", + channel3: "#sigfreibad", + channel4: "#faui2k15", port: 6667, server: "irc.fau.de", }