Add a very basic hash generator
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
parent
3b1d344fb9
commit
1221f6a5a4
1 changed files with 14 additions and 2 deletions
|
@ -1,16 +1,28 @@
|
||||||
import telebot, asyncdispatch, logging, options, strutils
|
import telebot, std/[asyncdispatch, logging, options, strutils, random]
|
||||||
var L = newConsoleLogger(fmtStr="$levelname, [$time] ")
|
var L = newConsoleLogger(fmtStr="$levelname, [$time] ")
|
||||||
addHandler(L)
|
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
|
# remember to strip your secret key to avoid HTTP error
|
||||||
const API_KEY = ""
|
const API_KEY = ""
|
||||||
|
|
||||||
proc updateHandler(b: Telebot, u: Update): Future[bool] {.async.} =
|
proc updateHandler(b: Telebot, u: Update): Future[bool] {.async.} =
|
||||||
var response = u.message.get
|
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:
|
if response.photo.isSome:
|
||||||
|
echo generate_hash()
|
||||||
discard await b.sendPhoto(response.chat.id, response.photo.get[0].fileId)
|
discard await b.sendPhoto(response.chat.id, response.photo.get[0].fileId)
|
||||||
echo "Found file"
|
echo "Found file"
|
||||||
#discard await b.sendMessage(response.chat.id, text, parseMode = "markdown", disableNotification = true, replyToMessageId = response.messageId)
|
|
||||||
|
|
||||||
let bot = newTeleBot(API_KEY)
|
let bot = newTeleBot(API_KEY)
|
||||||
bot.onUpdate(updateHandler)
|
bot.onUpdate(updateHandler)
|
||||||
|
|
Loading…
Reference in a new issue