commit ba7d3b64b417d13ffe38b2629f32df32836ce847
parent 2051dab54600ea40cd20ccdfa3dc870202d468a7
Author: ctucx <c@ctu.cx>
Date: Wed, 15 Jan 2020 12:39:02 +0100
parent 2051dab54600ea40cd20ccdfa3dc870202d468a7
Author: ctucx <c@ctu.cx>
Date: Wed, 15 Jan 2020 12:39:02 +0100
now uses nimble
7 files changed, 52 insertions(+), 54 deletions(-)
diff --git a/.gitignore b/.gitignore @@ -1,2 +1,2 @@ ctucxbot -secret.key +src/secret.key
diff --git a/ctucxbot.nim b/ctucxbot.nim @@ -1,48 +0,0 @@ -import asyncdispatch, telebot, options, strutils, random, os -include cmd/[uptime, yesorno] - -const API_KEY = slurp("secret.key") - -proc updateHandler(bot: Telebot, update: Update) {.async.} = - if not update.message.isNone: - var response = update.message.get - if response.text.isSome: - var text = response.text.get - - var answers = [ - "Höhö! Penis!", - "Schwaaaaaanz!", - "Gihihihi, Pimmel!", - "Höhö, Döödel!", - "Glied", - "8===D" - ] - - let penisCount = text.normalize.count("penis") - - if penisCount > 0: - if penisCount > 4: - var message = newPhoto(response.chat.id, "file://" & getCurrentDir() & "/data/pics/penis.jpg") - - message.replyToMessageId = response.messageId - discard await bot.send(message) - - else: - var message = newMessage(response.chat.id, sample(answers)) - - message.replyToMessageId = response.messageId - discard await bot.send(message) - - if text == "egg_irl": - var message = newPhoto(response.chat.id, "file://" & getCurrentDir() & "/data/pics/egg.jpg") - - message.replyToMessageId = response.messageId - discard await bot.send(message) - - -let bot = newTeleBot(API_KEY) - -bot.onUpdate(updateHandler) -bot.onCommand("uptime", uptimeCmd) -bot.onCommand("yesorno", yesornoCmd) -bot.poll(timeout=300)- \ No newline at end of file
diff --git a/ctucxbot.nimble b/ctucxbot.nimble @@ -12,3 +12,4 @@ bin = @["ctucxbot"] # Dependencies requires "nim >= 1.0.4" +requires "telebot >= 0.7.0"+ \ No newline at end of file
diff --git a/src/ctucxbot.nim b/src/ctucxbot.nim @@ -1,5 +1,48 @@ -# This is just an example to get you started. A typical binary package -# uses this file as the main entry point of the application. +import asyncdispatch, telebot, options, strutils, random, os +include cmd/[uptime, yesorno] -when isMainModule: - echo("Hello, World!") +const API_KEY = slurp("secret.key") + +proc updateHandler(bot: Telebot, update: Update) {.async.} = + if not update.message.isNone: + var response = update.message.get + if response.text.isSome: + var text = response.text.get + + var answers = [ + "Höhö! Penis!", + "Schwaaaaaanz!", + "Gihihihi, Pimmel!", + "Höhö, Döödel!", + "Glied", + "8===D" + ] + + let penisCount = text.normalize.count("penis") + + if penisCount > 0: + if penisCount > 4: + var message = newPhoto(response.chat.id, "file://" & getCurrentDir() & "/data/pics/penis.jpg") + + message.replyToMessageId = response.messageId + discard await bot.send(message) + + else: + var message = newMessage(response.chat.id, sample(answers)) + + message.replyToMessageId = response.messageId + discard await bot.send(message) + + if text == "egg_irl": + var message = newPhoto(response.chat.id, "file://" & getCurrentDir() & "/data/pics/egg.jpg") + + message.replyToMessageId = response.messageId + discard await bot.send(message) + + +let bot = newTeleBot(API_KEY) + +bot.onUpdate(updateHandler) +bot.onCommand("uptime", uptimeCmd) +bot.onCommand("yesorno", yesornoCmd) +bot.poll(timeout=300)+ \ No newline at end of file