--- /dev/null
+import json
+import os
+import random
+from datetime import datetime
+
+import pytz
+import tools.smart_privmsg
+from aptbot.bot import Bot, Commands, Message
+from scripts.subathon import sock
+
+PERMISSION = 10
+PREFIX = "\\"
+DESCRIPTION = ""
+USER_COOLDOWN = 0
+GLOBAL_COOLDOWN = 0
+
+
+COMMANDS_PATH = os.path.dirname(os.path.realpath(__file__))
+PATH = os.path.join(COMMANDS_PATH, "..")
+
+
+def main(bot: Bot, message: Message):
+ subcommand = message.value.split(" ")[1]
+ time = message.value.split(" ")[2]
+ try:
+ time = int(time)
+ except ValueError:
+ tools.smart_privmsg.send_safe(
+ bot,
+ message.channel,
+ "You need to put the number second. For example: \\timer add 300",
+ )
+ return
+ if subcommand == "add":
+ add_time(time)
+ elif subcommand == "set":
+ set_time(time)
+ elif subcommand == "now":
+ now()
+ else:
+ tools.smart_privmsg.send_safe(
+ bot,
+ message.channel,
+ "You need to use a valid command. Possible sub commands are 'add' 'set' and 'now'",
+ )
+ return
+ accepted_path = os.path.join(DATA_PATH, "jokes")
+ with open(accepted_path, "r") as f:
+ jokes = [user_id.rstrip() for user_id in f]
+ joke = random.choice(jokes)
+
+ tools.smart_privmsg.send(bot, message, f"{joke}", reply=message.tags["id"])
+
+
+def set_time(ts: int):
+ data = {
+ "set_ts": ts,
+ }
+ sock.send(json.dumps(data).encode())
+
+
+def add_time(ts: int):
+ data = {
+ "add_ts": ts,
+ }
+ sock.send(json.dumps(data).encode())
+
+
+def now():
+ data = {
+ "set_ts": datetime.now(pytz.UTC),
+ }
+ sock.send(json.dumps(data).encode())