diff --git a/boddle.db b/boddle.db index 31db554..c6dd3ea 100644 Binary files a/boddle.db and b/boddle.db differ diff --git a/boddle.go b/boddle.go index 50a6807..11c733a 100644 --- a/boddle.go +++ b/boddle.go @@ -5,10 +5,11 @@ import ( "fmt" "regexp" "database/sql" + "math/rand" _ "github.com/mattn/go-sqlite3" ) -var begin_char = []byte{'-', '<'} +var begin_char = []byte{'-'} var db *sql.DB var err error @@ -278,6 +279,18 @@ func parsemsg(msg *irc_msg, foo bot) bool { return false } if c.cmd == "help" { + (*msg).retmsg = "There is no help in this hell..." + return false + } + if c.cmd == "slap" { + who := []string{(*msg).author, "\x01ACTION"} + whom := []string{(*msg).author, foo.Conf.Name} + LOG_WARN.Printf("suffix: " + c.suffix) + if c.suffix != "" { + who = append(who, strings.Split(c.suffix, " ")...) + whom = append(whom, strings.Split(c.suffix, " ")...) + } + (*msg).retmsg = who[rand.Intn(len(who))] + " slaps " + whom[rand.Intn(len(whom))] + " around with a large trout." return false } // hard code 'groups' to add new groups to the groups-table diff --git a/bot.go b/bot.go index 3f68137..c2598df 100644 --- a/bot.go +++ b/bot.go @@ -18,23 +18,22 @@ func sendmsg (conn net.Conn, channel string, msg string) { conn.Write([]byte(mesg)) } -func scanline_privmsg (msg string) irc_msg { - var irc irc_msg +func scanline_privmsg (msg string, irc *irc_msg) { + LOG_ERR.Printf(msg) msg = msg[1:] t := strings.Split(msg, "!") - irc.author, irc.channel = t[0], t[1] - t = strings.Split(irc.channel, "PRIVMSG ") - irc.channel = t[1] - t = strings.Split(irc.channel, " :") - irc.channel, irc.msg = t[0], t[1] - t = strings.Split(irc.msg, "\r\n") - irc.msg = strings.TrimSpace(t[0]) - if ! strings.HasPrefix(irc.channel, "#") { - irc.channel = irc.author + (*irc).author, (*irc).channel = t[0], t[1] + t = strings.Split((*irc).channel, "PRIVMSG ") + (*irc).channel = t[1] + t = strings.Split((*irc).channel, " :") + (*irc).channel, (*irc).msg = t[0], t[1] + t = strings.Split((*irc).msg, "\r\n") + (*irc).msg = strings.TrimSpace(t[0]) + if ! strings.HasPrefix((*irc).channel, "#") { + (*irc).channel = (*irc).author } - irc.retmsg = "" - return irc + (*irc).retmsg = "" } func bot_connect(bot *bot) { @@ -113,7 +112,9 @@ func bot_listen(bot *bot) <-chan string { time.Sleep(10 * time.Second) bot_register(bot) } else if strings.Contains(line, "PRIVMSG") { - msg := scanline_privmsg(line) + var msg irc_msg + scanline_privmsg(line, &msg) + LOG_ERR.Printf(msg.author) parsemsg(&msg, (*bot)) if msg.retmsg != "" { sendmsg((*bot).conn, msg.channel, msg.retmsg) diff --git a/bot.py b/bot.py index d623236..21ecae9 100644 --- a/bot.py +++ b/bot.py @@ -12,7 +12,7 @@ import sqlite3 as sql updater = Updater(token='935673062:AAH4By1EMqAUaD9wgnV3lZQRRBX6e5Lve6g', use_context=True) # sqlite database -connection = sql.connect("/home/horscchtey/bots/boddle/src/v2/boddle.db", check_same_thread=False) +connection = sql.connect("/home/boddle/boddle/src/v2/boddle.db", check_same_thread=False) cursor = connection.cursor() dispatcher = updater.dispatcher diff --git a/forraspidothis b/forraspidothis index d295ea6..6239be8 100755 --- a/forraspidothis +++ b/forraspidothis @@ -1,15 +1,10 @@ #!/bin/bash -export GOPATH=/home/horscchtey/go -export CC=arm-linux-gnueabihf-gcc -export CXX=arm-linux-gnueabihf-g++ +export GOPATH=/home/boddle/go export CGO_ENABLED=1 -export GOOS=linux -export GOARCH=arm -export GOARM=7 declare -a src src+=(bot.go boddle.go logging.go helpers.go types.go) declare -i nproc="$(nproc)" -go build -p ${nproc} "${src[@]}" +go build -v -p ${nproc} "${src[@]}" diff --git a/go.mod b/go.mod index ef1cee4..72f9306 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.17 require ( github.com/distributedio/configo v0.0.0-20200107073829-efd79b027816 - github.com/mattn/go-sqlite3 v1.14.12 + github.com/mattn/go-sqlite3 v1.14.16 ) require ( diff --git a/go.sum b/go.sum index eb5290c..cb9d486 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ github.com/distributedio/configo v0.0.0-20200107073829-efd79b027816 h1:V6TyTUY0v github.com/distributedio/configo v0.0.0-20200107073829-efd79b027816/go.mod h1:Jwz2omP6W/T/XlSfu+BMGW7NEJX3tf5/Qv5gwaiQ+uU= github.com/mattn/go-sqlite3 v1.14.12 h1:TJ1bhYJPV44phC+IMu1u2K/i5RriLTPe+yc68XDJ1Z0= github.com/mattn/go-sqlite3 v1.14.12/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= +github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/naoina/go-stringutil v0.1.0 h1:rCUeRUHjBjGTSHl0VC00jUPLz8/F9dDzYI70Hzifhks= github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h1USek5+NqSA0= github.com/naoina/toml v0.1.1 h1:PT/lllxVVN0gzzSqSlHEmP8MJB4MY2U7STGxiouV4X8=