This repository has been archived on 2023-07-05. You can view files and clone it, but cannot push or open issues or pull requests.
clessy/mods/main.go

59 lines
1.2 KiB
Go
Raw Normal View History

2016-02-09 10:01:05 +00:00
package main
import (
"flag"
2016-02-09 10:46:40 +00:00
"strings"
2016-02-09 10:01:05 +00:00
2016-02-09 14:55:37 +00:00
"github.com/hamcha/clessy/tg"
2016-02-09 10:01:05 +00:00
)
func initmods() {
initviaggi()
2016-02-19 16:35:43 +00:00
initmeme()
2016-06-20 15:38:00 +00:00
initunsplash()
2017-01-09 21:58:12 +00:00
initmacro()
}
2016-02-09 10:01:05 +00:00
func dispatch(broker *tg.Broker, update tg.APIMessage) {
metafora(broker, update)
viaggi(broker, update)
2016-02-20 20:40:24 +00:00
memegen(broker, update)
2016-06-20 15:38:00 +00:00
unsplash(broker, update)
2017-01-09 21:58:12 +00:00
macro(broker, update)
2016-02-09 10:01:05 +00:00
}
2016-02-09 10:46:40 +00:00
func isCommand(update tg.APIMessage, cmdname string) bool {
if update.Text == nil {
return false
}
text := *(update.Text)
return strings.HasPrefix(text, "/"+cmdname+"@"+*botname) || (strings.HasPrefix(text, "/"+cmdname) && !strings.Contains(text, "@"))
}
var botname *string
2016-02-19 16:35:43 +00:00
var impact *string
2016-06-20 15:38:00 +00:00
var gillmt *string
2016-02-09 10:46:40 +00:00
2016-02-09 10:01:05 +00:00
func main() {
brokerAddr := flag.String("broker", "localhost:7314", "Broker address:port")
2016-02-09 10:46:40 +00:00
botname = flag.String("botname", "maudbot", "Bot name for /targetet@commands")
2016-02-19 16:35:43 +00:00
impact = flag.String("impact", "impact.ttf", "Path to impact.ttf (Impact font)")
2016-06-20 15:38:00 +00:00
gillmt = flag.String("gillmt", "gill.ttf", "Path to gill.ttf (Gill Sans MT font)")
2017-01-09 21:58:12 +00:00
macropath = flag.String("macropath", "macros.json", "Path to macros db (JSON)")
2016-02-09 10:01:05 +00:00
flag.Parse()
initmods()
2016-02-09 10:01:05 +00:00
err := tg.CreateBrokerClient(*brokerAddr, dispatch)
if err != nil {
panic(err)
}
}
2016-02-19 16:35:43 +00:00
func assert(err error) {
if err != nil {
panic(err)
}
}