mirror of
https://git.klmp200.net/ALFRED/ALFRED.git
synced 2025-01-18 18:46:44 +01:00
58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
/*
|
|
* @Author: Bartuccio Antoine
|
|
* @Date: 2018-07-23 15:24:22
|
|
* @Last Modified by: klmp200
|
|
* @Last Modified time: 2018-07-24 15:21:53
|
|
*/
|
|
|
|
package main
|
|
|
|
import (
|
|
"./commands"
|
|
"./settings"
|
|
"./shared"
|
|
tb "gopkg.in/tucnak/telebot.v2"
|
|
"log"
|
|
"time"
|
|
)
|
|
|
|
func main() {
|
|
registered_commands := map[string]func(*tb.Message){
|
|
tb.OnText: commands.OnText,
|
|
"/hello": commands.Hello,
|
|
"/sponge": commands.Sponge,
|
|
"/git": commands.Git,
|
|
"/framapad": commands.Framapad,
|
|
"/setgender": commands.SetGender,
|
|
"/gender": commands.Gender,
|
|
}
|
|
|
|
if err := settings.LoadSettings("settings.json", "settings_custom.json"); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
log.Println("Initialize history")
|
|
shared.InitHistory(int(settings.Settings["history size"].(float64)),
|
|
settings.Settings["history file"].(string))
|
|
log.Println("Initialize users infos")
|
|
shared.InitUsers(settings.Settings["users file"].(string))
|
|
|
|
log.Println("Bot initialisation")
|
|
b, err := tb.NewBot(tb.Settings{
|
|
Token: settings.Settings["token"].(string),
|
|
Poller: &tb.LongPoller{Timeout: 10 * time.Second},
|
|
})
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
return
|
|
}
|
|
shared.Bot = b
|
|
|
|
for key, value := range registered_commands {
|
|
b.Handle(key, value)
|
|
}
|
|
|
|
log.Println("Starting bot")
|
|
b.Start()
|
|
}
|