Add readme and revoke commands

This commit is contained in:
Ehmry - 2019-12-26 11:10:15 +05:30
parent c84e2c2902
commit f314e966db
1 changed files with 22 additions and 2 deletions

View File

@ -3,6 +3,7 @@ import toxcore
import std/asyncdispatch, std/base64, std/json, std/httpclient, std/os, std/strutils
const
readmeText = readFile "README.md"
spaceApiUrl = "http://spaceapi.hq.c3d2.de:3000/spaceapi.json"
saveFileName = "hqtoxbot.save"
adminIds = [
@ -11,8 +12,11 @@ const
]
proc bootstrap(bot: Tox) =
const servers = [ ("tox.neuland.technology",
"15E9C309CFCB79FDDF0EBA057DABB49FE15F3803B1BFF06536AE2E5BA5E4690E".toPublicKey)]
const servers = [
( "tox.neuland.technology",
"15E9C309CFCB79FDDF0EBA057DABB49FE15F3803B1BFF06536AE2E5BA5E4690E".toPublicKey
)
]
for host, key in servers.items:
bot.bootstrap(host, key)
@ -40,6 +44,8 @@ type Command = enum
help,
invite,
lock,
readme,
revoke,
unlock,
proc setup(bot: Tox) =
@ -57,6 +63,9 @@ proc setup(bot: Tox) =
if status != TOX_CONNECTION_NONE:
bot.invite(f, conference)
bot.onFriendReadReceipt do (f: friend; id; MessageId):
discard """TODO some commands should be defered until a read receipt is acquired. Maybe just revoke."""
bot.onFriendMessage do (f: Friend; msg: string; kind: MessageType):
proc reply(msg: string) =
discard bot.send(f, msg)
@ -90,6 +99,10 @@ proc setup(bot: Tox) =
of lock:
reply("""Lock the HQ door. """ &
"""If the door is already open his command is not effective.""")
of readme:
reply """Return bot README"""
of revoke:
reply """Remove yourself from the bot roster."""
of unlock:
reply """Unlock the HQ door."""
@ -116,6 +129,13 @@ proc setup(bot: Tox) =
else:
reply(fut.read.status)
of readme:
reply readmeText
of revoke:
reply """Tchuss"""
discard bot.delete(f)
of unlock:
bot.typing(f, true)
let fut = schalterClient.post("http://schalter.hq.c3d2.de/door/unlock")