From 1221f6a5a43e74ac6ac79fe1912aaf955c1facb6 Mon Sep 17 00:00:00 2001 From: baalajimaestro Date: Thu, 7 Apr 2022 17:15:56 +0530 Subject: [PATCH] Add a very basic hash generator Signed-off-by: baalajimaestro --- src/nim_censor_bot.nim | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/nim_censor_bot.nim b/src/nim_censor_bot.nim index 956bd1a..5ad253c 100644 --- a/src/nim_censor_bot.nim +++ b/src/nim_censor_bot.nim @@ -1,16 +1,28 @@ -import telebot, asyncdispatch, logging, options, strutils +import telebot, std/[asyncdispatch, logging, options, strutils, random] var L = newConsoleLogger(fmtStr="$levelname, [$time] ") addHandler(L) +proc generate_hash(): string= + result = newString(7) + const charset = {'a' .. 'z', 'A' .. 'Z', '0' .. '9'} + for i in 0..6: + result[i] = sample(charset) + return result + # 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.document.isSome: + + #if response.video.isSome: + #if response.videoNote.isSome: + #if response.animation.isSome: if response.photo.isSome: + echo generate_hash() 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)