Update repository
This commit is contained in:
parent
e5a935a85b
commit
df2a986286
7 changed files with 35 additions and 24 deletions
BIN
boddle.db
BIN
boddle.db
Binary file not shown.
15
boddle.go
15
boddle.go
|
|
@ -5,10 +5,11 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"math/rand"
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var begin_char = []byte{'-', '<'}
|
var begin_char = []byte{'-'}
|
||||||
var db *sql.DB
|
var db *sql.DB
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
|
@ -278,6 +279,18 @@ func parsemsg(msg *irc_msg, foo bot) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if c.cmd == "help" {
|
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
|
return false
|
||||||
}
|
}
|
||||||
// hard code 'groups' to add new groups to the groups-table
|
// hard code 'groups' to add new groups to the groups-table
|
||||||
|
|
|
||||||
29
bot.go
29
bot.go
|
|
@ -18,23 +18,22 @@ func sendmsg (conn net.Conn, channel string, msg string) {
|
||||||
conn.Write([]byte(mesg))
|
conn.Write([]byte(mesg))
|
||||||
}
|
}
|
||||||
|
|
||||||
func scanline_privmsg (msg string) irc_msg {
|
func scanline_privmsg (msg string, irc *irc_msg) {
|
||||||
var irc irc_msg
|
LOG_ERR.Printf(msg)
|
||||||
|
|
||||||
msg = msg[1:]
|
msg = msg[1:]
|
||||||
t := strings.Split(msg, "!")
|
t := strings.Split(msg, "!")
|
||||||
irc.author, irc.channel = t[0], t[1]
|
(*irc).author, (*irc).channel = t[0], t[1]
|
||||||
t = strings.Split(irc.channel, "PRIVMSG ")
|
t = strings.Split((*irc).channel, "PRIVMSG ")
|
||||||
irc.channel = t[1]
|
(*irc).channel = t[1]
|
||||||
t = strings.Split(irc.channel, " :")
|
t = strings.Split((*irc).channel, " :")
|
||||||
irc.channel, irc.msg = t[0], t[1]
|
(*irc).channel, (*irc).msg = t[0], t[1]
|
||||||
t = strings.Split(irc.msg, "\r\n")
|
t = strings.Split((*irc).msg, "\r\n")
|
||||||
irc.msg = strings.TrimSpace(t[0])
|
(*irc).msg = strings.TrimSpace(t[0])
|
||||||
if ! strings.HasPrefix(irc.channel, "#") {
|
if ! strings.HasPrefix((*irc).channel, "#") {
|
||||||
irc.channel = irc.author
|
(*irc).channel = (*irc).author
|
||||||
}
|
}
|
||||||
irc.retmsg = ""
|
(*irc).retmsg = ""
|
||||||
return irc
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func bot_connect(bot *bot) {
|
func bot_connect(bot *bot) {
|
||||||
|
|
@ -113,7 +112,9 @@ func bot_listen(bot *bot) <-chan string {
|
||||||
time.Sleep(10 * time.Second)
|
time.Sleep(10 * time.Second)
|
||||||
bot_register(bot)
|
bot_register(bot)
|
||||||
} else if strings.Contains(line, "PRIVMSG") {
|
} 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))
|
parsemsg(&msg, (*bot))
|
||||||
if msg.retmsg != "" {
|
if msg.retmsg != "" {
|
||||||
sendmsg((*bot).conn, msg.channel, msg.retmsg)
|
sendmsg((*bot).conn, msg.channel, msg.retmsg)
|
||||||
|
|
|
||||||
2
bot.py
2
bot.py
|
|
@ -12,7 +12,7 @@ import sqlite3 as sql
|
||||||
updater = Updater(token='935673062:AAH4By1EMqAUaD9wgnV3lZQRRBX6e5Lve6g', use_context=True)
|
updater = Updater(token='935673062:AAH4By1EMqAUaD9wgnV3lZQRRBX6e5Lve6g', use_context=True)
|
||||||
|
|
||||||
# sqlite database
|
# 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()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
dispatcher = updater.dispatcher
|
dispatcher = updater.dispatcher
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
export GOPATH=/home/horscchtey/go
|
export GOPATH=/home/boddle/go
|
||||||
export CC=arm-linux-gnueabihf-gcc
|
|
||||||
export CXX=arm-linux-gnueabihf-g++
|
|
||||||
export CGO_ENABLED=1
|
export CGO_ENABLED=1
|
||||||
export GOOS=linux
|
|
||||||
export GOARCH=arm
|
|
||||||
export GOARM=7
|
|
||||||
|
|
||||||
declare -a src
|
declare -a src
|
||||||
src+=(bot.go boddle.go logging.go helpers.go types.go)
|
src+=(bot.go boddle.go logging.go helpers.go types.go)
|
||||||
declare -i nproc="$(nproc)"
|
declare -i nproc="$(nproc)"
|
||||||
|
|
||||||
go build -p ${nproc} "${src[@]}"
|
go build -v -p ${nproc} "${src[@]}"
|
||||||
|
|
|
||||||
2
go.mod
2
go.mod
|
|
@ -4,7 +4,7 @@ go 1.17
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/distributedio/configo v0.0.0-20200107073829-efd79b027816
|
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 (
|
require (
|
||||||
|
|
|
||||||
2
go.sum
2
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/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 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.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 h1:rCUeRUHjBjGTSHl0VC00jUPLz8/F9dDzYI70Hzifhks=
|
||||||
github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h1USek5+NqSA0=
|
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=
|
github.com/naoina/toml v0.1.1 h1:PT/lllxVVN0gzzSqSlHEmP8MJB4MY2U7STGxiouV4X8=
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue