-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrouter.go
97 lines (76 loc) · 3.23 KB
/
router.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package main
import (
"github.com/CoreDumped-ETSISI/etsisi-telegram-bot/cmds/bus"
"github.com/CoreDumped-ETSISI/etsisi-telegram-bot/cmds/exam"
"github.com/CoreDumped-ETSISI/etsisi-telegram-bot/cmds/guides"
"github.com/CoreDumped-ETSISI/etsisi-telegram-bot/cmds/help"
"github.com/CoreDumped-ETSISI/etsisi-telegram-bot/cmds/horario"
"github.com/CoreDumped-ETSISI/etsisi-telegram-bot/cmds/janitor"
"github.com/CoreDumped-ETSISI/etsisi-telegram-bot/cmds/menu"
"github.com/CoreDumped-ETSISI/etsisi-telegram-bot/cmds/news"
"github.com/CoreDumped-ETSISI/etsisi-telegram-bot/cmds/salas"
"github.com/CoreDumped-ETSISI/etsisi-telegram-bot/cmds/status"
"github.com/CoreDumped-ETSISI/etsisi-telegram-bot/cmds/subscription"
"github.com/CoreDumped-ETSISI/etsisi-telegram-bot/cmds/tts"
"github.com/CoreDumped-ETSISI/etsisi-telegram-bot/cmds/verify"
"github.com/guad/commander"
)
// Note that underscores (_) are forbidden for command names.
func route(cmd *commander.CommandGroup, cfg config, callbacks *commander.CommandGroup) {
cmd.Command("/menu", menu.CafeTodayCmd)
cmd.Command("/menu2", menu.CafeTomorrowCmd)
cmd.Command("/menumañana", menu.CafeTomorrowCmd)
cmd.Command("/salas", salas.SalasCmd)
cmd.Command("/noticias", news.NewsCmd)
cmd.Command("/avisos", news.AvisosCmd)
cmd.Command("/coredumped", news.CoreCmd)
cmd.Command("/help", help.HelpCmd)
cmd.Command("/start {data*}", verify.PrivateOnlyMiddleware(help.Start))
cmd.Command("/subscribe {feed?}", janitor.AdminOnlyMiddleware(subscription.SubscribeCmd(cfg.db)))
cmd.Command("/unsubscribe {feed?}", janitor.AdminOnlyMiddleware(subscription.UnsubscribeCmd(cfg.db)))
cmd.Command("/canales", subscription.GetAllChannelsCommand)
go subscription.StartMonitoringSubscriptions(cfg.redis, cfg.bot, cfg.db)
cmd.Command("/horario {grupo?}", horario.HorarioCmd)
cmd.Command("/horario2 {grupo?}", horario.HorarioWeekCmd)
cmd.Command("/status", status.StatusCmd)
cmd.Command("/statusbot", status.BotStatusCmd)
cmd.Command("/bus {stop:int?}", bus.BusCmd)
cmd.Command("/tts", tts.TtsCmd)
cmd.Command("/exam", exam.ExamCmd)
cmd.Command("/guias", guides.GuideCmd)
cmd.Command("/gg {code}", guides.DownloadGuideCmd)
cmd.Command("/manage", janitor.AdminOnlyMiddleware(janitor.Manage))
cmd.Command("/ban",
janitor.AdminOnlyMiddleware(
janitor.ManagedOnlyMiddleware(janitor.Ban),
),
)
cmd.Command("/unban {user:int}",
janitor.AdminOnlyMiddleware(
janitor.ManagedOnlyMiddleware(janitor.Unban),
),
)
cmd.Command("/verificar", verify.PrivateOnlyMiddleware(verify.Cmd))
go verify.StartListening()
// Callbacks
callbacks.Command("/gpag {grado} {offset:int}", guides.PaginateGradoCallback)
callbacks.Command("/exyear {grado}", exam.SelectYearCb)
callbacks.Command("/exshow {grado} {curso:int}", exam.ShowExamsCb)
callbacks.Command("/jannyrefresh {chatid} {public}",
janitor.AdminOnlyMiddleware(
janitor.ManagedOnlyMiddleware(janitor.RefreshCb),
),
)
callbacks.Command("/jannypublictoggle {chatid} {public}",
janitor.AdminOnlyMiddleware(
janitor.ManagedOnlyMiddleware(janitor.TogglePublicCb),
),
)
callbacks.Command("/jannydisable {chatid}",
janitor.AdminOnlyMiddleware(
janitor.ManagedOnlyMiddleware(janitor.DisableCb),
),
)
// Events
cmd.Event("update", janitor.OnUpdate)
}