only do Request matching on the provided chat
authorEduardo <[email protected]>
Fri, 29 Mar 2024 01:36:36 +0000 (02:36 +0100)
committerEduardo <[email protected]>
Fri, 29 Mar 2024 01:36:36 +0000 (02:36 +0100)
bot.go
telegram.go

diff --git a/bot.go b/bot.go
index 791af43e07956b6a3cf1a86935ef6007b4f47955..346466e9324746e1a0f8fa0fa7a2a38a30836a5d 100644 (file)
--- a/bot.go
+++ b/bot.go
@@ -16,9 +16,13 @@ const (
 )
 
 var (
+       // tokens
        TgApiToken   = "7113650816:AAFBlE-AAeLxIv6Kawk4OohtQ72pz55_s_4"
        DiscApiToken = "MTIwMzg0MzAyMDg5ODgzMjM5NA.G6e3Eo.yU90uQzHOMCw-cHguOhzwlXhnIcHo5YId60U64"
 
+       // chat ids
+       TgRequestInputChatID int64 = -4189177318
+       TgRequestChannelID   int64 = -1002057743103
 
        menuTextMarkup = tgbotapi.NewInlineKeyboardMarkup(
                tgbotapi.NewInlineKeyboardRow(
index 0c165707c55d436fff61757ad7bef569752bb28e..dbc691068e153d9882f91b3236cadc013da2838e 100644 (file)
@@ -106,19 +106,26 @@ func handleConversation(chatId int64, text string) error {
        text = trimMultipleSpaces(text)
        text = strings.ToLower(text)
 
-       var regexIssue = regexp.MustCompile(`(?i)\bIssue\b`)
-       var regexRequest = regexp.MustCompile(`(?i)\bRequest\b`)
+       // Check if the chat is the request channel
+       if chatId == TgRequestInputChatID {
+               var regexIssue = regexp.MustCompile(`(?i)\bIssue\b`)
+               var regexRequest = regexp.MustCompile(`(?i)\bRequest\b`)
+
+               switch {
+               case regexIssue.MatchString(text):
+                       err = manageIssueMessage(chatId, text)
+                       return err
+
+               case regexRequest.MatchString(text):
+                       err = manageSerieRequest(chatId, text)
+                       return err
+               }
+       }
 
        switch {
        case onlineOnRoles(text):
                err = sendMenu(chatId)
 
-       case regexIssue.MatchString(text):
-               err = manageIssueMessage(chatId, text)
-
-       case regexRequest.MatchString(text):
-               err = manageSerieRequest(chatId, text)
-
        case saludo(text):
                err = sendTelegramMessage(chatId, "Hola!")