ctucx.git: ctucxbot

[nimlang] A telegram bot

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 import asyncdispatch, telebot, strutils, options, json

proc debuginfoCommand* (bot: Telebot, command: Command): Future[bool] {.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
      }
    }
  }

  discard await bot.sendMessage(command.message.chat.id, "```" & pretty(json) & "```", replyToMessageId = command.message.messageId, parseMode = "markdown")