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
2016-06-20 17:38:00 +02:00

55 lines
1.1 KiB
Go

package main
import (
"flag"
"strings"
"github.com/hamcha/clessy/tg"
)
func initmods() {
initviaggi()
initmeme()
initunsplash()
}
func dispatch(broker *tg.Broker, update tg.APIMessage) {
metafora(broker, update)
viaggi(broker, update)
memegen(broker, update)
unsplash(broker, update)
}
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
var impact *string
var gillmt *string
func main() {
brokerAddr := flag.String("broker", "localhost:7314", "Broker address:port")
botname = flag.String("botname", "maudbot", "Bot name for /targetet@commands")
impact = flag.String("impact", "impact.ttf", "Path to impact.ttf (Impact font)")
gillmt = flag.String("gillmt", "gill.ttf", "Path to gill.ttf (Gill Sans MT font)")
flag.Parse()
initmods()
err := tg.CreateBrokerClient(*brokerAddr, dispatch)
if err != nil {
panic(err)
}
}
func assert(err error) {
if err != nil {
panic(err)
}
}