diff --git a/src/boddle.db b/src/boddle.db index c68bb08cdb3af69e5f08e528e0c83da0c4d58b6a..4aa0804767f195347b79f931cf817c77f8e97e81 100644 Binary files a/src/boddle.db and b/src/boddle.db differ diff --git a/src/bot.go b/src/bot.go index 4ff1568af8dfb8c1779c6da1b3cae07945b2b2ca..b04e18306c7adaa4243b1edaec5e781d7d8057a5 100644 --- a/src/bot.go +++ b/src/bot.go @@ -12,6 +12,7 @@ import "database/sql" import _ "github.com/mattn/go-sqlite3" var dead = true +var arsch = false type irc_msg struct { channel string @@ -52,7 +53,7 @@ func scanline_privmsg (msg string) irc_msg { t = strings.Split(irc.channel, " :") irc.channel, irc.msg = t[0], t[1] t = strings.Split(irc.msg, "\r\n") - irc.msg = t[0] + irc.msg = strings.TrimSpace(t[0]) if ! strings.HasPrefix(irc.channel, "#") { irc.channel = irc.author } @@ -79,26 +80,6 @@ func parsemsg(line string, foo bot) bool { "zinn_des_lebens": true, } -/* - 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, " ") @@ -128,10 +109,14 @@ func parsemsg(line string, foo bot) bool { 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>" + case "hate": + helpmsg = "get hate messages with >hate or hate with your best friend using >hate <your love>" case "add jokes": helpmsg = "type >add jokes for more information" case "add flirt": helpmsg = "add your best pick up line using >add flirt <pickup line>" + case "add hate": + helpmsg = "add your best break up line using >add hate <breakup line>" case "geh schlafen": helpmsg = "send the bot to sleep until the next reconnect" case "deutsch": @@ -147,6 +132,14 @@ func parsemsg(line string, foo bot) bool { fmt.Sprintf(strings.Join(functs, ", ")))) } + } else if strings.Compare(ircmsg.msg, ">arsch on") == 0 && strings.Compare(ircmsg.author, "horscchtey") == 0 { + // info + arsch = true + sendmsg(foo.conn, ircmsg.channel, "OH YEAH BABY") + } else if strings.Compare(ircmsg.msg, ">arsch off") == 0 && strings.Compare(ircmsg.author, "horscchtey") == 0 { + // info + arsch = false + sendmsg(foo.conn, ircmsg.channel, "dis not gud") } else if strings.Compare(ircmsg.msg, ">info") == 0 { // info sendmsg(foo.conn, ircmsg.channel, "created in golang with love, cats and tears >:)") @@ -268,26 +261,41 @@ func parsemsg(line string, foo bot) bool { if err != nil { fmt.Printf("nargh") } - fmt.Printf(joke) _, err = statement.Exec(count, curr, joke); if err != nil { panic(err) return true } sendmsg(foo.conn, ircmsg.channel, "i guess that worked") - } 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 ") { + } else if strings.HasPrefix(ircmsg.msg, ">wisdom") { + // wisdom + db, err := sql.Open("sqlite3", "./boddle.db") + if err != nil { + panic(err) + return true + } + + rows, err := db.Query("select e.wisdom from wisdom e ORDER BY RANDOM() LIMIT 1") + if err != nil { + panic(err) + return true + } + var wisdom string + for rows.Next() { + var curr string + rows.Scan(&curr) + wisdom = curr + } + rows.Close() + + sendmsg(foo.conn, ircmsg.channel, wisdom) + } else if strings.HasPrefix(ircmsg.msg, ">flirt") { // flirt - var ppl []string - if strings.HasPrefix(ircmsg.msg, ">flirt") { - for _, v := range strings.Split(ircmsg.msg, " ") { - if ! strings.HasPrefix(v, ">flirt") { - ppl = append(ppl, v) - } - } + var ppl string + if len(ircmsg.msg) > 7 { + ppl = string(([]rune(ircmsg.msg))[7:len(ircmsg.msg)]) } else { - ppl = append(ppl,ircmsg.author) + ppl = ircmsg.author } db, err := sql.Open("sqlite3", "./boddle.db") @@ -309,12 +317,77 @@ func parsemsg(line string, foo bot) bool { } rows.Close() - if (len(ppl) == 0) { - sendmsg(foo.conn, ircmsg.channel, flirt) + endstring := len(flirt)-1 + + for endstring > 0 { + curr := int(flirt[endstring]) + if (curr > 64 && curr < 91) || (curr > 96 && curr < 123) { + break; + } + endstring = endstring - 1 + } + endstring = endstring + 1 + var outstr string + if (endstring > 0) && (endstring < len(flirt)) { + outstr = fmt.Sprintf("%s, %s%s <3", + string(flirt[0:endstring]), + ppl, + string(flirt[endstring:len(flirt)]) ) + } else { + outstr = fmt.Sprintf("%s, %s <3", + flirt, ppl ) + } + + sendmsg(foo.conn, ircmsg.channel, outstr) + } else if strings.HasPrefix(ircmsg.msg, ">hate") { + // hate + var ppl string + if len(ircmsg.msg) > 6 { + ppl = string(([]rune(ircmsg.msg))[6:len(ircmsg.msg)]) + } else { + ppl = ircmsg.author + } + + db, err := sql.Open("sqlite3", "./boddle.db") + if err != nil { + panic(err) + return true + } + + rows, err := db.Query("select e.hate from hate e ORDER BY RANDOM() LIMIT 1") + if err != nil { + panic(err) return true + } + var hate string + for rows.Next() { + var curr string + rows.Scan(&curr) + hate = curr + } + rows.Close() + + endstring := len(hate)-1 + + for endstring > 0 { + curr := int(hate[endstring]) + if (curr > 64 && curr < 91) || (curr > 96 && curr < 123) { + break; + } + endstring = endstring - 1 + } + endstring = endstring + 1 + var outstr string + if (endstring > 0) && (endstring < len(hate)) { + outstr = fmt.Sprintf("%s, %s%s :/", + string(hate[0:endstring]), + ppl, + string(hate[endstring:len(hate)]) ) } else { - sendmsg(foo.conn, ircmsg.channel, fmt.Sprintf("%s, %s <3", flirt, fmt.Sprintf(strings.Join(ppl, ", ")))) + outstr = fmt.Sprintf("%s, %s :/", + hate, ppl ) } + sendmsg(foo.conn, ircmsg.channel, outstr) } 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") { @@ -353,6 +426,95 @@ 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, ">add flirt") { + if ! jokeusers[ircmsg.author] { + sendmsg(foo.conn, ircmsg.channel, "ur a cum-puter sciene student, learn how to flirt!") + } + t := strings.SplitN(ircmsg.msg, "add flirt ",2) + if len(t) != 2 { + sendmsg(foo.conn, ircmsg.channel, fmt.Sprintf("usage: add flirt <really romantic stuff here>")) + return true + } + flirt := t[1] + + // open database + db, err := sql.Open("sqlite3", "./boddle.db") + if err != nil { + panic(err) + return true + } + + // get number of jokes + var count int + row := db.QueryRow("SELECT COUNT(*) FROM flirt") + err = row.Scan(&count) + if err != nil { + fmt.Printf("num failed\n") + } + // insert ... + statement, err := db.Prepare ("insert into flirt (id, flirt) values (?,?)") + if err != nil { + fmt.Printf("nargh") + } + _, err = statement.Exec(count, flirt); + if err != nil { + panic(err) + return true + } + sendmsg(foo.conn, ircmsg.channel, "congrats, no woman will ever like you") + } else if strings.HasPrefix(ircmsg.msg, ">add hate") { + if ! jokeusers[ircmsg.author] { + sendmsg(foo.conn, ircmsg.channel, "ur a cum-puter sciene student, learn how to hate!") + } + t := strings.SplitN(ircmsg.msg, "add hate ",2) + if len(t) != 2 { + sendmsg(foo.conn, ircmsg.channel, fmt.Sprintf("usage: add hate <really romantic stuff here>")) + return true + } + hate := t[1] + + // open database + db, err := sql.Open("sqlite3", "./boddle.db") + if err != nil { + panic(err) + return true + } + // insert ... + statement, err := db.Prepare ("insert into hate (hate) values (?)") + if err != nil { + fmt.Printf("nargh") + } + _, err = statement.Exec(hate); + if err != nil { + panic(err) + return true + } + sendmsg(foo.conn, ircmsg.channel, "congrats, no woman will ever like you") + } else if strings.HasPrefix(ircmsg.msg, ">add wisdom") { + t := strings.SplitN(ircmsg.msg, "add wisdom ",2) + if len(t) != 2 { + sendmsg(foo.conn, ircmsg.channel, fmt.Sprintf("usage: add wisdom <really romantic stuff here>")) + return true + } + wisdom := t[1] + + // open database + db, err := sql.Open("sqlite3", "./boddle.db") + if err != nil { + panic(err) + return true + } + // insert ... + statement, err := db.Prepare ("insert into wisdom (wisdom) values (?)") + if err != nil { + fmt.Printf("nargh") + } + _, err = statement.Exec(wisdom); + if err != nil { + panic(err) + return true + } + sendmsg(foo.conn, ircmsg.channel, "wise words added") } else if strings.HasPrefix(ircmsg.msg, ">idb") { // idb t := strings.SplitN(ircmsg.msg, " ", 2) @@ -451,6 +613,15 @@ func parsemsg(line string, foo bot) bool { sorrybro := "Sorry bro I did not understand that..." helpingoffer := "you can type >help for more information on my skills" sendmsg(foo.conn, ircmsg.channel, fmt.Sprintf("%s %s", sorrybro, helpingoffer)) + } else if (rand.Int()%50) == 0 && arsch == true { + var words []string + for _, v := range strings.Split(ircmsg.msg, " ") { + words = append(words, v) + } + if len(words) > 2 { + words[rand.Int()%len(words)] = "arsch" + } + sendmsg(foo.conn, ircmsg.channel, fmt.Sprintf(strings.Join(words, " "))) } return true }