ctucx.git: ctucxbot

[nimlang] A telegram bot

commit 7a2396292ef87bf5f8ad2d3d25c6f85f0a89b12d
parent d2c5ade2771b8e570fca55fec8f7bfd12adf2df0
Author: ctucx <c@ctu.cx>
Date: Thu, 16 Jan 2020 12:02:43 +0100

new command: /utc
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/cmd/utc.nim b/src/cmd/utc.nim
@@ -0,0 +1,8 @@
+import asyncdispatch, telebot, strutils, times 
+proc utcCommand(bot: Telebot, command: Command) {.async.} =
+  let time = now().utc
+  
+  var message = newMessage(command.message.chat.id, time.format("dd'.'MM'.'yyyy' 'HH':'mm"))
+  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, uptime, yesorno, whoami]
+include cmd/[animalpics, daysuntilcongress, help, stats, unixtime, utc, uptime, yesorno, whoami]
 
 const API_KEY = slurp("secret.key")
 

@@ -65,6 +65,7 @@ bot.onCommand("catgif", animalCommand(cat, true))
 bot.onCommand("help", helpCommand)
 bot.onCommand("stats", statsCommand)
 bot.onCommand("unixtime", unixtimeCommand)
+bot.onCommand("utc", utcCommand)
 bot.onCommand("uptime", uptimeCommand)
 bot.onCommand("yesorno", yesornoCommand)
 bot.onCommand("whoami", whoamiCommand)