From 5eac4c95d535feaa2cdbda912f53e65bdf61ed3c Mon Sep 17 00:00:00 2001 From: baalajimaestro Date: Sun, 17 Apr 2022 15:00:51 +0530 Subject: [PATCH] Move the response to switchinline Signed-off-by: baalajimaestro --- nim_censor_bot.nimble | 2 +- src/nim_censor_bot.nim | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/nim_censor_bot.nimble b/nim_censor_bot.nimble index 86ea456..e28d3e4 100644 --- a/nim_censor_bot.nimble +++ b/nim_censor_bot.nimble @@ -11,5 +11,5 @@ bin = @["nim_censor_bot"] # Dependencies requires "nim >= 1.6.0" -requires "telebot >= 2022.02.02" +requires "telebot >= 2022.04.17" requires "norm >= 2.4.0" diff --git a/src/nim_censor_bot.nim b/src/nim_censor_bot.nim index a16df9f..42f010a 100644 --- a/src/nim_censor_bot.nim +++ b/src/nim_censor_bot.nim @@ -191,7 +191,9 @@ proc updateHandler(b: Telebot, u: Update): Future[bool] {.async, gcsafe.} = var CensoredRow = NewCensoredData(ftype, filehash, fileid, epochTime(), fcaption) with dbConn: insert CensoredRow - discard await b.sendMessage(response.chat.id, "*Censored " & capitalizeAscii(ftype) & "*\n\n[Tap to View](tg://resolve?domain=" & b.username & "&start=" & filehash & ")", parseMode = "Markdown") + var replybutton = InlineKeyboardButton(text: "Share", switchInlineQuery: some(filehash)) + let replymark = newInlineKeyboardMarkup(@[replybutton]) + discard await b.sendMessage(response.chat.id, "*Censored " & capitalizeAscii(ftype) & "*", replyMarkup = replymark, parseMode="Markdown") else: let filehash = GroupMedia[parseInt(response.mediaGroupId.get)] var CensoredRow = NewCensoredData(ftype, filehash, fileid, epochTime(), fcaption) @@ -203,7 +205,9 @@ proc updateHandler(b: Telebot, u: Update): Future[bool] {.async, gcsafe.} = var CensoredRow = NewCensoredData(ftype, filehash, fileid, epochTime(), fcaption) with dbConn: insert CensoredRow - discard await b.sendMessage(response.chat.id, "*Censored " & capitalizeAscii(ftype) & "*\n\n[Tap to View](tg://resolve?domain=" & b.username & "&start=" & filehash & ")", parseMode = "Markdown") + var replybutton = InlineKeyboardButton(text: "Share", switchInlineQuery: some(filehash)) + let replymark = newInlineKeyboardMarkup(@[replybutton]) + discard await b.sendMessage(response.chat.id, "*Censored " & capitalizeAscii(ftype) & "*", replyMarkup = replymark, parseMode="Markdown") OldDataCleanup() # Start the bot