@@ -36,23 +36,6 @@ func main() {
3636 })
3737 dispatcher := updater .Dispatcher
3838
39- // Handlers for running commands.
40- dispatcher .AddHandler (handlers .NewCommand ("start" , start ))
41- dispatcher .AddHandler (handlers .NewCommand ("help" , help ))
42- dispatcher .AddHandler (handlers .NewCommand ("source" , source ))
43- dispatcher .AddHandler (handlers .NewCommand ("ignore" , ignoreChannel ))
44- dispatcher .AddHandler (handlers .NewCommand ("unignore" , unignoreChannel ))
45- dispatcher .AddHandler (handlers .NewCommand ("ignorelist" , ignoreList ))
46- dispatcher .AddHandlerToGroup (
47- handlers .NewMessage (
48- func (msg * gotgbot.Message ) bool {
49- return msg .GetSender ().IsAnonymousChannel ()
50- },
51- restrictChannels ,
52- ),
53- - 1 ,
54- )
55-
5639 if enableWebhook {
5740 log .Println ("[Webhook] Starting webhook..." )
5841 webhookOpts := ext.WebhookOpts {
@@ -80,6 +63,10 @@ func main() {
8063
8164 log .Println ("[Webhook] Webhook started Successfully!" )
8265 } else {
66+ success , err := b .DeleteWebhook (& gotgbot.DeleteWebhookOpts {DropPendingUpdates : true })
67+ if err != nil || ! success {
68+ log .Fatalf ("[Polling] Failed to delete webhook: %s\n " , err .Error ())
69+ }
8370 err = updater .StartPolling (b , & ext.PollingOpts {DropPendingUpdates : false })
8471 if err != nil {
8572 log .Fatalf ("[Polling] Failed to start polling: %s\n " , err .Error ())
@@ -90,6 +77,23 @@ func main() {
9077 // log msg telling that bot has started
9178 log .Printf ("%s has been started...!\n Made with ❤️ by @DivideProjects\n " , b .User .Username )
9279
80+ // Handlers for running commands.
81+ dispatcher .AddHandler (handlers .NewCommand ("start" , start ))
82+ dispatcher .AddHandler (handlers .NewCommand ("help" , help ))
83+ dispatcher .AddHandler (handlers .NewCommand ("source" , source ))
84+ dispatcher .AddHandler (handlers .NewCommand ("ignore" , ignoreChannel ))
85+ dispatcher .AddHandler (handlers .NewCommand ("unignore" , unignoreChannel ))
86+ dispatcher .AddHandler (handlers .NewCommand ("ignorelist" , ignoreList ))
87+ dispatcher .AddHandlerToGroup (
88+ handlers .NewMessage (
89+ func (msg * gotgbot.Message ) bool {
90+ return msg .GetSender ().IsAnonymousChannel ()
91+ },
92+ restrictChannels ,
93+ ),
94+ - 1 ,
95+ )
96+
9397 // Idle, to keep updates coming in, and avoid bot stopping.
9498 updater .Idle ()
9599}
0 commit comments