Add sub counter command master
authorGeorgios Atheridis <georgios@atheridis.org>
Sat, 1 Jul 2023 13:22:25 +0000 (14:22 +0100)
committerGeorgios Atheridis <georgios@atheridis.org>
Sat, 1 Jul 2023 13:22:25 +0000 (14:22 +0100)
ihaspeks/commands/subs.py [new file with mode: 0644]

diff --git a/ihaspeks/commands/subs.py b/ihaspeks/commands/subs.py
new file mode 100644 (file)
index 0000000..0b0f65e
--- /dev/null
@@ -0,0 +1,30 @@
+import os
+import sqlite3
+
+import tools.smart_privmsg
+from aptbot.bot import Bot, Commands, Message
+
+PERMISSION = 99
+PREFIX = "?"
+DESCRIPTION = ""
+USER_COOLDOWN = 60
+GLOBAL_COOLDOWN = 30
+
+
+COMMANDS_PATH = os.path.dirname(os.path.realpath(__file__))
+PATH = os.path.join(COMMANDS_PATH, "..")
+
+
+def main(bot: Bot, message: Message):
+    conn = sqlite3.connect(os.path.join(PATH, "subathon.db"))
+    c = conn.cursor()
+
+    c.execute(
+        f"""
+        select sum(sub_count) from subs;
+        """
+    )
+    fetched = c.fetchone()[0]
+    conn.close()
+    msg = f"We are currently sitting at {int(fetched)} SUBS!!!!! ihaspeHappy"
+    tools.smart_privmsg.send_safe(bot, message.channel, msg)