From 16315062c67b7111f9674fe040802908b7851265 Mon Sep 17 00:00:00 2001 From: Eduardo Date: Fri, 29 Mar 2024 02:36:36 +0100 Subject: [PATCH] only do Request matching on the provided chat --- bot.go | 4 ++++ telegram.go | 23 +++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/bot.go b/bot.go index 791af43..346466e 100644 --- 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( diff --git a/telegram.go b/telegram.go index 0c16570..dbc6910 100644 --- a/telegram.go +++ b/telegram.go @@ -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!") -- 2.30.2