Add readme and revoke commands
This commit is contained in:
parent
c84e2c2902
commit
f314e966db
|
@ -3,6 +3,7 @@ import toxcore
|
||||||
import std/asyncdispatch, std/base64, std/json, std/httpclient, std/os, std/strutils
|
import std/asyncdispatch, std/base64, std/json, std/httpclient, std/os, std/strutils
|
||||||
|
|
||||||
const
|
const
|
||||||
|
readmeText = readFile "README.md"
|
||||||
spaceApiUrl = "http://spaceapi.hq.c3d2.de:3000/spaceapi.json"
|
spaceApiUrl = "http://spaceapi.hq.c3d2.de:3000/spaceapi.json"
|
||||||
saveFileName = "hqtoxbot.save"
|
saveFileName = "hqtoxbot.save"
|
||||||
adminIds = [
|
adminIds = [
|
||||||
|
@ -11,8 +12,11 @@ const
|
||||||
]
|
]
|
||||||
|
|
||||||
proc bootstrap(bot: Tox) =
|
proc bootstrap(bot: Tox) =
|
||||||
const servers = [ ("tox.neuland.technology",
|
const servers = [
|
||||||
"15E9C309CFCB79FDDF0EBA057DABB49FE15F3803B1BFF06536AE2E5BA5E4690E".toPublicKey)]
|
( "tox.neuland.technology",
|
||||||
|
"15E9C309CFCB79FDDF0EBA057DABB49FE15F3803B1BFF06536AE2E5BA5E4690E".toPublicKey
|
||||||
|
)
|
||||||
|
]
|
||||||
for host, key in servers.items:
|
for host, key in servers.items:
|
||||||
bot.bootstrap(host, key)
|
bot.bootstrap(host, key)
|
||||||
|
|
||||||
|
@ -40,6 +44,8 @@ type Command = enum
|
||||||
help,
|
help,
|
||||||
invite,
|
invite,
|
||||||
lock,
|
lock,
|
||||||
|
readme,
|
||||||
|
revoke,
|
||||||
unlock,
|
unlock,
|
||||||
|
|
||||||
proc setup(bot: Tox) =
|
proc setup(bot: Tox) =
|
||||||
|
@ -57,6 +63,9 @@ proc setup(bot: Tox) =
|
||||||
if status != TOX_CONNECTION_NONE:
|
if status != TOX_CONNECTION_NONE:
|
||||||
bot.invite(f, conference)
|
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):
|
bot.onFriendMessage do (f: Friend; msg: string; kind: MessageType):
|
||||||
proc reply(msg: string) =
|
proc reply(msg: string) =
|
||||||
discard bot.send(f, msg)
|
discard bot.send(f, msg)
|
||||||
|
@ -90,6 +99,10 @@ proc setup(bot: Tox) =
|
||||||
of lock:
|
of lock:
|
||||||
reply("""Lock the HQ door. """ &
|
reply("""Lock the HQ door. """ &
|
||||||
"""If the door is already open his command is not effective.""")
|
"""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:
|
of unlock:
|
||||||
reply """Unlock the HQ door."""
|
reply """Unlock the HQ door."""
|
||||||
|
|
||||||
|
@ -116,6 +129,13 @@ proc setup(bot: Tox) =
|
||||||
else:
|
else:
|
||||||
reply(fut.read.status)
|
reply(fut.read.status)
|
||||||
|
|
||||||
|
of readme:
|
||||||
|
reply readmeText
|
||||||
|
|
||||||
|
of revoke:
|
||||||
|
reply """Tchuss"""
|
||||||
|
discard bot.delete(f)
|
||||||
|
|
||||||
of unlock:
|
of unlock:
|
||||||
bot.typing(f, true)
|
bot.typing(f, true)
|
||||||
let fut = schalterClient.post("http://schalter.hq.c3d2.de/door/unlock")
|
let fut = schalterClient.post("http://schalter.hq.c3d2.de/door/unlock")
|
||||||
|
|
Loading…
Reference in New Issue