import asyncdispatch, strformat, telebot const COMMANDS = [ # command arguments description [ "daysuntilcongress", "", "prints the number of days till congress." ], [ "help", "[[command]]", "prints the description of the given command." ], [ "stats", "", "print some stats…dunno?" ], [ "uptime", "", "prints the uptime of this bot." ], [ "yesorno", "", "helps with decisions." ], ] proc helpCommand* (bot: Telebot, command: Command): Future[bool] {.async.} = var answer = "" if command.params.len() > 0: let command = command.params answer = fmt"Could not find Command ›/{command}‹" for index in 0..( COMMANDS.len() - 1 ): let entry = COMMANDS[ index ] if entry[ 0 ] == command: let arguments = entry[ 1 ] let description = entry[ 2 ] answer = fmt"/{command} {arguments}{'\n'} {description}" break else: answer = "This Bot reacts to messages…\n" answer &= "…starting with ›/‹ (see below),\n" answer &= "…containing ›penis‹,\n" answer &= "…containing ›/s‹ somewhere.\n" answer &= "Available Commands:" for index in 0..( COMMANDS.len() - 1 ): let entry = COMMANDS[ index ] let command = entry[ 0 ] let arguments = entry[ 1 ] let description = entry[ 2 ] answer &= fmt"{'\n'}/{command} {arguments} – {description}" discard await bot.sendMessage(command.message.chat.id, answer, replyToMessageId = command.message.messageId, parseMode = "markdown")