commit 3b1d344fb90e5304c4d9f398f0e4e56c3e22acb1 Author: baalajimaestro Date: Thu Apr 7 16:21:02 2022 +0530 Root Commit Signed-off-by: baalajimaestro diff --git a/nim.cfg b/nim.cfg new file mode 100644 index 0000000..ace4e9c --- /dev/null +++ b/nim.cfg @@ -0,0 +1 @@ +-d:ssl \ No newline at end of file diff --git a/nim_censor_bot.nimble b/nim_censor_bot.nimble new file mode 100644 index 0000000..86430e4 --- /dev/null +++ b/nim_censor_bot.nimble @@ -0,0 +1,14 @@ +# Package + +version = "0.1.0" +author = "baalajimaestro" +description = "Censor Bot for Telegram written in Nim" +license = "AGPL-3.0-or-later" +srcDir = "src" +bin = @["nim_censor_bot"] + + +# Dependencies + +requires "nim >= 1.6.0" +requires "telebot" \ No newline at end of file diff --git a/src/nim_censor_bot.nim b/src/nim_censor_bot.nim new file mode 100644 index 0000000..956bd1a --- /dev/null +++ b/src/nim_censor_bot.nim @@ -0,0 +1,17 @@ +import telebot, asyncdispatch, logging, options, strutils +var L = newConsoleLogger(fmtStr="$levelname, [$time] ") +addHandler(L) + +# remember to strip your secret key to avoid HTTP error +const API_KEY = "" + +proc updateHandler(b: Telebot, u: Update): Future[bool] {.async.} = + var response = u.message.get + if response.photo.isSome: + discard await b.sendPhoto(response.chat.id, response.photo.get[0].fileId) + echo "Found file" + #discard await b.sendMessage(response.chat.id, text, parseMode = "markdown", disableNotification = true, replyToMessageId = response.messageId) + +let bot = newTeleBot(API_KEY) +bot.onUpdate(updateHandler) +bot.poll(timeout=300)