Skip to content

Commit 5c08da1

Browse files
committed
feat: disable functionality and show info message on command
1 parent 477e770 commit 5c08da1

3 files changed

Lines changed: 32 additions & 6 deletions

File tree

cmd/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"net/url"
77
"os"
88
"os/user"
9-
"time"
109

1110
"github.com/d-Rickyy-b/gogeizhalsbot/v2/internal/bot"
1211
"github.com/d-Rickyy-b/gogeizhalsbot/v2/internal/config"
@@ -38,8 +37,9 @@ func main() {
3837
log.Println("Loaded proxies:", len(proxies))
3938
}
4039

41-
updateInterval := time.Duration(botConfig.UpdateIntervalMinutes) * time.Minute
42-
go bot.UpdatePricesJob(updateInterval)
40+
// Disable price update job for now
41+
//updateInterval := time.Duration(botConfig.UpdateIntervalMinutes) * time.Minute
42+
//go bot.UpdatePricesJob(updateInterval)
4343

4444
proxy.InitProxies(proxies)
4545
bot.Start(botConfig)

internal/bot/bot.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,10 @@ func setCommands() {
394394
// addMessageHandlers adds all the message handlers to the dispatcher. This tells our bot how to handle updates.
395395
func addMessageHandlers(dispatcher *ext.Dispatcher) {
396396
// Text commands
397-
dispatcher.AddHandler(handlers.NewCommand("start", startHandler))
398-
dispatcher.AddHandler(handlers.NewCommand("stop", stopHandler))
397+
dispatcher.AddHandler(handlers.NewCommand("start", maintenanceHandler))
398+
dispatcher.AddHandler(handlers.NewCommand("stop", maintenanceHandler))
399399
dispatcher.AddHandler(handlers.NewCommand("version", versionHandler))
400-
dispatcher.AddHandler(handlers.NewCommand("help", helpHandler))
400+
dispatcher.AddHandler(handlers.NewCommand("help", maintenanceHandler))
401401

402402
// Callback Queries (inline keyboards)
403403
dispatcher.AddHandler(handlers.NewCallback(callbackquery.Equal(StopCancelState), stopHandlerCancel))

internal/bot/maintenancehandler.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package bot
2+
3+
import (
4+
"fmt"
5+
"log"
6+
7+
"github.com/PaulSonOfLars/gotgbot/v2"
8+
"github.com/PaulSonOfLars/gotgbot/v2/ext"
9+
)
10+
11+
// maintenanceHandler
12+
func maintenanceHandler(bot *gotgbot.Bot, ctx *ext.Context) error {
13+
maintenanceText := fmt.Sprintf("Hallo lieber Nutzer und vielen Dank für dein Interesse an diesem Bot.\n\nVor einiger Zeit wurde die Geizhals Webseite umgestaltet, wodurch der Bot keine Daten mehr auslesen kann. Aktuell schaffe ich es zeitlich nicht, den Bot an die neue Seite anzupassen. Diese Anpassung kommt mit erheblichem Aufwand daher, weshalb ich den Bot erst einmal deaktiviert habe.\n\nWenn du programmieren kannst, schau dir gerne den %s an - vielleicht hast du gerade etwas Zeit zum unterstützen?\n\nVielen Dank für dein Verständnis!", createLink("https://github.com/d-Rickyy-b/GoGeizhalsBot", "Quellcode auf GitHub"))
14+
_, replyErr := ctx.EffectiveMessage.Reply(bot, maintenanceText, &gotgbot.SendMessageOpts{
15+
ParseMode: "HTML",
16+
LinkPreviewOptions: &gotgbot.LinkPreviewOptions{
17+
IsDisabled: true,
18+
},
19+
})
20+
21+
if replyErr != nil {
22+
log.Println(replyErr)
23+
}
24+
25+
return nil
26+
}

0 commit comments

Comments
 (0)