summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralex2018-10-21 13:14:08 +0100
committeralex2018-10-21 13:14:08 +0100
commit19716c3afbf5902e208a32215dd1c63ec7c5a9f6 (patch)
treed062635ecba6a8125464515ee8ed451ab76cef3b
parent61b84d9fd997d61f4e5bb6adc63a2310036a242e (diff)
downloadwatbot-19716c3afbf5902e208a32215dd1c63ec7c5a9f6.tar.gz
watbot-19716c3afbf5902e208a32215dd1c63ec7c5a9f6.tar.bz2
watbot-19716c3afbf5902e208a32215dd1c63ec7c5a9f6.zip
added admin command for impersonating any irc command
remove db
-rw-r--r--.gitignore1
-rw-r--r--wat/bot.go37
2 files changed, 24 insertions, 14 deletions
diff --git a/.gitignore b/.gitignore
index 942fa54..3fe8f4e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
# personal reasons (。◕ ‿ ◕。)
+*.db
*.tgz
# ---> Go
# Binaries for programs and plugins
diff --git a/wat/bot.go b/wat/bot.go
index 170f77e..b51948d 100644
--- a/wat/bot.go
+++ b/wat/bot.go
@@ -38,24 +38,33 @@ func (w *WatBot) HandleIrcMsg(c *irc.Client, m *irc.Message) {
}
}
+func (w *WatBot) Admin(m *irc.Message) bool {
+ return m.Prefix.Host == "tripsit/operator/hibs"
+}
+
func (w *WatBot) Msg(m *irc.Message) {
- if m.Params[0] == w.Nick && m.Prefix.Host == "tripsit/operator/hibs" {
- if "join" == m.Params[1] {
- w.write("JOIN", "##wat")
- }
+ if !strings.Contains(m.Prefix.Host, "tripsit") || (m.Params[0] != "##wat" && m.Params[0] != "##test" && !w.Admin(m)) {
+ return
}
- if strings.Contains(m.Prefix.Host, "tripsit") && m.Params[0] == "##wat" {
- args := strings.FieldsFunc(m.Params[1], func(c rune) bool {return c == ' '})
- if len(args) < 1 && args[0] != "wat" && args[0][0] != '#' {
- return
- }
- if args[0][0] == '#' {
- args[0] = args[0][1:]
+
+ args := strings.FieldsFunc(m.Params[1], func(c rune) bool {return c == ' '})
+
+ if w.Admin(m) {
+ // Do a special admin command and return, or continue
+ if args[0] == "imp" {
+ w.write(args[1], args[2:]...)
}
- user := strings.ToLower(m.Prefix.Name)
- player := w.Db.User(user, m.Prefix.Host, true)
- w.game.Msg(m, &player, args)
}
+
+ if len(args) < 1 && args[0] != "wat" && args[0][0] != '#' {
+ return
+ }
+ if args[0][0] == '#' {
+ args[0] = args[0][1:]
+ }
+ user := strings.ToLower(m.Prefix.Name)
+ player := w.Db.User(user, m.Prefix.Host, true)
+ w.game.Msg(m, &player, args)
}
func (w *WatBot) Run() {