mirror of
https://git.klmp200.net/ALFRED/ALFRED.git
synced 2025-01-18 10:36:44 +01:00
Externalized all commands in corresponding package
This commit is contained in:
parent
f7f3308372
commit
7336770332
30
alfred.go
30
alfred.go
@ -2,7 +2,7 @@
|
||||
* @Author: Bartuccio Antoine
|
||||
* @Date: 2018-07-23 15:24:22
|
||||
* @Last Modified by: klmp200
|
||||
* @Last Modified time: 2018-07-24 11:58:31
|
||||
* @Last Modified time: 2018-07-24 12:35:08
|
||||
*/
|
||||
|
||||
package main
|
||||
@ -17,6 +17,14 @@ import (
|
||||
)
|
||||
|
||||
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,
|
||||
}
|
||||
|
||||
if err := settings.LoadSettings("settings.json", "settings_custom.json"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -35,23 +43,9 @@ func main() {
|
||||
}
|
||||
shared.Bot = b
|
||||
|
||||
b.Handle("/hello", func(m *tb.Message) {
|
||||
b.Send(m.Chat, "Bonjour "+m.Sender.Username)
|
||||
})
|
||||
|
||||
b.Handle(tb.OnText, func(m *tb.Message) {
|
||||
shared.History.AddMessage(m.Chat.ID, m.Text)
|
||||
})
|
||||
|
||||
b.Handle("/sponge", commands.Sponge)
|
||||
|
||||
b.Handle("/git", func(m *tb.Message) {
|
||||
b.Send(m.Chat, "Mon code est accessible librement à l'adresse https://git.klmp200.net/ALFRED/ALFRED. Venez contribuer :)")
|
||||
})
|
||||
|
||||
b.Handle("/framapad", func(m *tb.Message) {
|
||||
b.Send(m.Chat, "Venez participer à mon développement en posant vos idées ici : https://mensuel.framapad.org/p/ALFRED2LERETOUR.")
|
||||
})
|
||||
for key, value := range registered_commands {
|
||||
b.Handle(key, value)
|
||||
}
|
||||
|
||||
log.Println("Starting bot")
|
||||
b.Start()
|
||||
|
17
commands/framapad.go
Normal file
17
commands/framapad.go
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* @Author: Bartuccio Antoine
|
||||
* @Date: 2018-07-24 12:11:26
|
||||
* @Last Modified by: klmp200
|
||||
* @Last Modified time: 2018-07-24 12:12:58
|
||||
*/
|
||||
|
||||
package commands
|
||||
|
||||
import (
|
||||
"../shared"
|
||||
tb "gopkg.in/tucnak/telebot.v2"
|
||||
)
|
||||
|
||||
func Framapad(m *tb.Message) {
|
||||
shared.Bot.Send(m.Chat, "Venez participer à mon développement en posant vos idées ici : https://mensuel.framapad.org/p/ALFRED2LERETOUR.")
|
||||
}
|
17
commands/git.go
Normal file
17
commands/git.go
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* @Author: Bartuccio Antoine
|
||||
* @Date: 2018-07-24 12:07:34
|
||||
* @Last Modified by: klmp200
|
||||
* @Last Modified time: 2018-07-24 12:08:49
|
||||
*/
|
||||
|
||||
package commands
|
||||
|
||||
import (
|
||||
"../shared"
|
||||
tb "gopkg.in/tucnak/telebot.v2"
|
||||
)
|
||||
|
||||
func Git(m *tb.Message) {
|
||||
shared.Bot.Send(m.Chat, "Mon code source est accessible librement à l'adresse https://git.klmp200.net/ALFRED/ALFRED. Venez contribuer :)")
|
||||
}
|
17
commands/hello.go
Normal file
17
commands/hello.go
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* @Author: Bartuccio Antoine
|
||||
* @Date: 2018-07-24 12:05:45
|
||||
* @Last Modified by: klmp200
|
||||
* @Last Modified time: 2018-07-24 12:06:39
|
||||
*/
|
||||
|
||||
package commands
|
||||
|
||||
import (
|
||||
"../shared"
|
||||
tb "gopkg.in/tucnak/telebot.v2"
|
||||
)
|
||||
|
||||
func Hello(m *tb.Message) {
|
||||
shared.Bot.Send(m.Chat, "Bonjour "+m.Sender.Username)
|
||||
}
|
17
commands/on_text.go
Normal file
17
commands/on_text.go
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* @Author: Bartuccio Antoine
|
||||
* @Date: 2018-07-24 12:09:37
|
||||
* @Last Modified by: klmp200
|
||||
* @Last Modified time: 2018-07-24 12:10:26
|
||||
*/
|
||||
|
||||
package commands
|
||||
|
||||
import (
|
||||
"../shared"
|
||||
tb "gopkg.in/tucnak/telebot.v2"
|
||||
)
|
||||
|
||||
func OnText(m *tb.Message) {
|
||||
shared.History.AddMessage(m.Chat.ID, m.Text)
|
||||
}
|
Loading…
Reference in New Issue
Block a user