commit 35530ea9504ef802d51a7a7e108e360b9dc9e288
parent 62dd43257aea19dd45559855e49c13244e8a436e
Author: ctucx <c@ctu.cx>
Date: Wed, 22 Jan 2020 18:26:27 +0100
parent 62dd43257aea19dd45559855e49c13244e8a436e
Author: ctucx <c@ctu.cx>
Date: Wed, 22 Jan 2020 18:26:27 +0100
new command: debuginfo
3 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/ctucxbot.nimble b/ctucxbot.nimble @@ -10,6 +10,5 @@ bin = @["ctucxbot"] # Dependencies - requires "nim >= 1.0.4" -requires "telebot >= 0.7.0"- \ No newline at end of file +requires "telebot >= 0.7.0"
diff --git a/src/cmd/debuginfo.nim b/src/cmd/debuginfo.nim @@ -0,0 +1,30 @@ +import asyncdispatch, telebot, strutils, options, json + +proc debuginfoCommand(bot: Telebot, command: Command) {.async.} = + var json = %*{ + "params": command.params, + "message": { + "messageId": command.message.messageId, + "fromUser": { + "id": command.message.fromUser.get.id, + "isBot": command.message.fromUser.get.isBot, + "firstName": command.message.fromUser.get.firstName, + "lastName": command.message.fromUser.get.lastName, + "username": command.message.fromUser.get.username, + "languageCode": command.message.fromUser.get.languageCode + }, + "date": command.message.date, + "chat": { + "id": command.message.chat.id, + "kind": command.message.chat.kind, + "title": command.message.chat.title, + "username": command.message.chat.username + } + } + } + + + var message = newMessage(command.message.chat.id, "```" & pretty(json) & "```") + message.replyToMessageId = command.message.messageId + message.parseMode = "markdown" + discard bot.send(message)+ \ No newline at end of file
diff --git a/src/ctucxbot.nim b/src/ctucxbot.nim @@ -1,5 +1,5 @@ import asyncdispatch, telebot, options, strutils, random, os, re, unicode -include cmd/[animalpics, daysuntilcongress, help, stats, unixtime, utc, uptime, yesorno, whoami] +include cmd/[animalpics, daysuntilcongress, debuginfo, help, stats, unixtime, utc, uptime, yesorno, whoami] proc ctrlcHandler() {.noconv.} = quit() @@ -65,6 +65,7 @@ if getEnv("API_KEY") != "": #bot.onCommand("penguin", animalCommand(penguin, false)) # pingudor.de is offline bot.onCommand("dog", animalCommand(dog, false)) bot.onCommand("doggo", animalCommand(dog, false)) + bot.onCommand("debuginfo", debuginfoCommand) bot.onCommand("cat", animalCommand(cat, false)) bot.onCommand("catgif", animalCommand(cat, true)) bot.onCommand("help", helpCommand)