From: Georgios Atheridis Date: Sat, 1 Jul 2023 13:22:25 +0000 (+0100) Subject: Add sub counter command X-Git-Url: https://git.atheridis.org/?a=commitdiff_plain;p=ihaspeks%2Faptbot-ihaspeks.git Add sub counter command --- diff --git a/ihaspeks/commands/subs.py b/ihaspeks/commands/subs.py new file mode 100644 index 0000000..0b0f65e --- /dev/null +++ b/ihaspeks/commands/subs.py @@ -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)