From: Georgios Atheridis Date: Thu, 19 May 2022 19:49:09 +0000 (+0000) Subject: added jokes X-Git-Url: https://git.atheridis.org/?a=commitdiff_plain;h=20dd40b21c98f03c740897868c09875be7cca3f1;p=ihaspeks%2Faptbot-ihaspeks.git added jokes --- diff --git a/skgyorugo/auto_messages/jokes.py b/skgyorugo/auto_messages/jokes.py new file mode 100644 index 0000000..ee98a47 --- /dev/null +++ b/skgyorugo/auto_messages/jokes.py @@ -0,0 +1,25 @@ +from aptbot.bot import Message, Commands, Bot +import tools.smart_privmsg +import urllib3 +import json + +COOLDOWN = 20 * 60 +END_TIME = 0 + +header = { + "Accept": "application/json", + "User-Agent": "For my twitch bot [MurphyAI] on https://twitch.tv/ihaspeks", +} + + +def main(bot: Bot, message: Message): + http = urllib3.PoolManager() + r = http.request("GET", "https://icanhazdadjoke.com", headers=header) + if r.status != 200: + tools.smart_privmsg.send(bot, message, f"Couldn't get a joke Sadge") + return + + data = json.loads(r.data.decode("utf-8")) + tools.smart_privmsg.send( + bot, message, f"{data['joke']} ||| Get more jokes by typing ?joke" + ) diff --git a/skgyorugo/commands/available.py b/skgyorugo/commands/available.py deleted file mode 100644 index d64f6e3..0000000 --- a/skgyorugo/commands/available.py +++ /dev/null @@ -1,260 +0,0 @@ -from aptbot.bot import Message, Commands, Bot -import os -import logging -import ttv_api.users -import sqlite3 -import time - -logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) - -PERMISSION = 99 -PREFIX = "?" -DESCRIPTION = r"Makes yourself available in the list." -USER_COOLDOWN = 600 -GLOBAL_COOLDOWN = 0 - -PATH = os.path.dirname(os.path.realpath(__file__)) -PATH = os.path.join(PATH, "..") - - -def main(bot: Bot, message: Message): - twitch = ttv_api.users.get_users(user_logins=[message.nick]) - if not twitch: - bot.send_privmsg( - message.channel, - "There was an issue fetching your twitch data. You weren't made unavailable.", - reply=message.tags["id"], - ) - return - twitch_id = twitch[0].user_id - conn = sqlite3.connect(os.path.join(PATH, "lol_data.db")) - c = conn.cursor() - - c.execute( - """ - UPDATE - lol_queue - SET - position = ( - CASE - WHEN ( - SELECT - position - FROM - lol_queue - WHERE - twitch_id = ? - ) < ( - SELECT - max(position) - FROM ( - SELECT - position - FROM - lol_queue - WHERE - available = 1 - ORDER BY - position - LIMIT ( - SELECT - data - FROM - lol_queue_data - WHERE - name = 'queuesize' - ) - ) - ) - THEN position + 1 - ELSE position - END - ) - WHERE - position > ( - SELECT - max(position) - FROM - lol_queue - WHERE - priority_queue = 1 - OR position <= ( - SELECT - max(position) - FROM ( - SELECT - position - FROM - lol_queue - WHERE - available = 1 - ORDER BY - position - LIMIT ( - SELECT - data - FROM - lol_queue_data - WHERE - name = 'queuesize' - ) - ) - - ) - ); - """, - (twitch_id,), - ) - - c.execute( - """ - UPDATE - lol_queue - SET - available = 1, - priority_queue = ( - CASE - WHEN ( - SELECT - position - FROM - lol_queue - WHERE - twitch_id = ? - ) < ( - SELECT - max(position) - FROM ( - SELECT - position - FROM - lol_queue - WHERE - available = 1 - ORDER BY - position - LIMIT ( - SELECT - data - FROM - lol_queue_data - WHERE - name = 'queuesize' - ) - ) - ) - THEN 1 - ELSE null - END - ), - position = ( - CASE - WHEN ( - SELECT - position - FROM - lol_queue - WHERE - twitch_id = ? - ) < ( - SELECT - max(position) - FROM ( - SELECT - position - FROM - lol_queue - WHERE - available = 1 - ORDER BY - position - LIMIT ( - SELECT - data - FROM - lol_queue_data - WHERE - name = 'queuesize' - ) - ) - ) - THEN 1 + ( - SELECT - max(position) - FROM - lol_queue - WHERE - priority_queue = 1 - OR position <= ( - SELECT - max(position) - FROM ( - SELECT - position - FROM - lol_queue - WHERE - available = 1 - ORDER BY - position - LIMIT ( - SELECT - data - FROM - lol_queue_data - WHERE - name = 'queuesize' - ) - ) - ) - ) - ELSE position - END - ), - time_remaining = time_remaining - (? - last_available) - WHERE - twitch_id = ? - AND available = 0; - """, - ( - twitch_id, - twitch_id, - int(time.time()), - twitch_id, - ), - ) - if c.rowcount < 1: - bot.send_privmsg( - message.channel, - "You aren't in the list or you were already available.", - reply=message.tags["id"], - ) - conn.close() - return - conn.commit() - c.execute("DELETE FROM lol_queue WHERE time_remaining < 0;") - if c.rowcount > 0: - bot.send_privmsg( - message.channel, - "You were unavailable for too long, you have been removed from the list.", - reply=message.tags["id"], - ) - conn.commit() - conn.close() - return - conn.commit() - bot.send_privmsg( - message.channel, - "Successfully made you available", - reply=message.tags["id"], - ) - conn.close() diff --git a/skgyorugo/commands/forceavailable.py b/skgyorugo/commands/forceavailable.py deleted file mode 100644 index 9427a12..0000000 --- a/skgyorugo/commands/forceavailable.py +++ /dev/null @@ -1,263 +0,0 @@ -from aptbot.bot import Message, Commands, Bot -import os -import logging -import ttv_api.users -import sqlite3 -import time - -logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) - -PERMISSION = 10 -PREFIX = "\\" -DESCRIPTION = r"Force user to become available in the list." -USER_COOLDOWN = 0 -GLOBAL_COOLDOWN = 0 - -PATH = os.path.dirname(os.path.realpath(__file__)) -PATH = os.path.join(PATH, "..") - - -def main(bot: Bot, message: Message): - twitch_name = message.tags.get("reply-parent-user-login", None) - if not twitch_name: - twitch_name = message.value.split(" ")[1] - twitch = ttv_api.users.get_users(user_logins=[twitch_name]) - if not twitch: - bot.send_privmsg( - message.channel, - "There was an issue fetching their twitch data. They weren't made unavailable.", - reply=message.tags["id"], - ) - return - twitch_id = twitch[0].user_id - conn = sqlite3.connect(os.path.join(PATH, "lol_data.db")) - c = conn.cursor() - - c.execute( - """ - UPDATE - lol_queue - SET - position = ( - CASE - WHEN ( - SELECT - position - FROM - lol_queue - WHERE - twitch_id = ? - ) < ( - SELECT - max(position) - FROM ( - SELECT - position - FROM - lol_queue - WHERE - available = 1 - ORDER BY - position - LIMIT ( - SELECT - data - FROM - lol_queue_data - WHERE - name = 'queuesize' - ) - ) - ) - THEN position + 1 - ELSE position - END - ) - WHERE - position > ( - SELECT - max(position) - FROM - lol_queue - WHERE - priority_queue = 1 - OR position <= ( - SELECT - max(position) - FROM ( - SELECT - position - FROM - lol_queue - WHERE - available = 1 - ORDER BY - position - LIMIT ( - SELECT - data - FROM - lol_queue_data - WHERE - name = 'queuesize' - ) - ) - - ) - ); - """, - (twitch_id,), - ) - - c.execute( - """ - UPDATE - lol_queue - SET - available = 1, - priority_queue = ( - CASE - WHEN ( - SELECT - position - FROM - lol_queue - WHERE - twitch_id = ? - ) < ( - SELECT - max(position) - FROM ( - SELECT - position - FROM - lol_queue - WHERE - available = 1 - ORDER BY - position - LIMIT ( - SELECT - data - FROM - lol_queue_data - WHERE - name = 'queuesize' - ) - ) - ) - THEN 1 - ELSE null - END - ), - position = ( - CASE - WHEN ( - SELECT - position - FROM - lol_queue - WHERE - twitch_id = ? - ) < ( - SELECT - max(position) - FROM ( - SELECT - position - FROM - lol_queue - WHERE - available = 1 - ORDER BY - position - LIMIT ( - SELECT - data - FROM - lol_queue_data - WHERE - name = 'queuesize' - ) - ) - ) - THEN 1 + ( - SELECT - max(position) - FROM - lol_queue - WHERE - priority_queue = 1 - OR position <= ( - SELECT - max(position) - FROM ( - SELECT - position - FROM - lol_queue - WHERE - available = 1 - ORDER BY - position - LIMIT ( - SELECT - data - FROM - lol_queue_data - WHERE - name = 'queuesize' - ) - ) - ) - ) - ELSE position - END - ), - time_remaining = time_remaining - (? - last_available) - WHERE - twitch_id = ? - AND available = 0; - """, - ( - twitch_id, - twitch_id, - int(time.time()), - twitch_id, - ), - ) - if c.rowcount < 1: - bot.send_privmsg( - message.channel, - "They aren't in the list or they were already available.", - reply=message.tags["id"], - ) - conn.close() - return - conn.commit() - c.execute("DELETE FROM lol_queue WHERE time_remaining < 0;") - if c.rowcount > 0: - bot.send_privmsg( - message.channel, - "They were unavailable for too long, they have been removed from the list.", - reply=message.tags["id"], - ) - conn.commit() - conn.close() - return - conn.commit() - bot.send_privmsg( - message.channel, - "Successfully made them available", - reply=message.tags["id"], - ) - conn.close() diff --git a/skgyorugo/commands/forcehere.py b/skgyorugo/commands/forcehere.py new file mode 100644 index 0000000..9427a12 --- /dev/null +++ b/skgyorugo/commands/forcehere.py @@ -0,0 +1,263 @@ +from aptbot.bot import Message, Commands, Bot +import os +import logging +import ttv_api.users +import sqlite3 +import time + +logger = logging.getLogger(__name__) +logger.setLevel(logging.DEBUG) + +formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") + +file_handler = logging.FileHandler("/var/log/aptbot/logs.log") +file_handler.setFormatter(formatter) + +logger.handlers = [] +logger.addHandler(file_handler) + +PERMISSION = 10 +PREFIX = "\\" +DESCRIPTION = r"Force user to become available in the list." +USER_COOLDOWN = 0 +GLOBAL_COOLDOWN = 0 + +PATH = os.path.dirname(os.path.realpath(__file__)) +PATH = os.path.join(PATH, "..") + + +def main(bot: Bot, message: Message): + twitch_name = message.tags.get("reply-parent-user-login", None) + if not twitch_name: + twitch_name = message.value.split(" ")[1] + twitch = ttv_api.users.get_users(user_logins=[twitch_name]) + if not twitch: + bot.send_privmsg( + message.channel, + "There was an issue fetching their twitch data. They weren't made unavailable.", + reply=message.tags["id"], + ) + return + twitch_id = twitch[0].user_id + conn = sqlite3.connect(os.path.join(PATH, "lol_data.db")) + c = conn.cursor() + + c.execute( + """ + UPDATE + lol_queue + SET + position = ( + CASE + WHEN ( + SELECT + position + FROM + lol_queue + WHERE + twitch_id = ? + ) < ( + SELECT + max(position) + FROM ( + SELECT + position + FROM + lol_queue + WHERE + available = 1 + ORDER BY + position + LIMIT ( + SELECT + data + FROM + lol_queue_data + WHERE + name = 'queuesize' + ) + ) + ) + THEN position + 1 + ELSE position + END + ) + WHERE + position > ( + SELECT + max(position) + FROM + lol_queue + WHERE + priority_queue = 1 + OR position <= ( + SELECT + max(position) + FROM ( + SELECT + position + FROM + lol_queue + WHERE + available = 1 + ORDER BY + position + LIMIT ( + SELECT + data + FROM + lol_queue_data + WHERE + name = 'queuesize' + ) + ) + + ) + ); + """, + (twitch_id,), + ) + + c.execute( + """ + UPDATE + lol_queue + SET + available = 1, + priority_queue = ( + CASE + WHEN ( + SELECT + position + FROM + lol_queue + WHERE + twitch_id = ? + ) < ( + SELECT + max(position) + FROM ( + SELECT + position + FROM + lol_queue + WHERE + available = 1 + ORDER BY + position + LIMIT ( + SELECT + data + FROM + lol_queue_data + WHERE + name = 'queuesize' + ) + ) + ) + THEN 1 + ELSE null + END + ), + position = ( + CASE + WHEN ( + SELECT + position + FROM + lol_queue + WHERE + twitch_id = ? + ) < ( + SELECT + max(position) + FROM ( + SELECT + position + FROM + lol_queue + WHERE + available = 1 + ORDER BY + position + LIMIT ( + SELECT + data + FROM + lol_queue_data + WHERE + name = 'queuesize' + ) + ) + ) + THEN 1 + ( + SELECT + max(position) + FROM + lol_queue + WHERE + priority_queue = 1 + OR position <= ( + SELECT + max(position) + FROM ( + SELECT + position + FROM + lol_queue + WHERE + available = 1 + ORDER BY + position + LIMIT ( + SELECT + data + FROM + lol_queue_data + WHERE + name = 'queuesize' + ) + ) + ) + ) + ELSE position + END + ), + time_remaining = time_remaining - (? - last_available) + WHERE + twitch_id = ? + AND available = 0; + """, + ( + twitch_id, + twitch_id, + int(time.time()), + twitch_id, + ), + ) + if c.rowcount < 1: + bot.send_privmsg( + message.channel, + "They aren't in the list or they were already available.", + reply=message.tags["id"], + ) + conn.close() + return + conn.commit() + c.execute("DELETE FROM lol_queue WHERE time_remaining < 0;") + if c.rowcount > 0: + bot.send_privmsg( + message.channel, + "They were unavailable for too long, they have been removed from the list.", + reply=message.tags["id"], + ) + conn.commit() + conn.close() + return + conn.commit() + bot.send_privmsg( + message.channel, + "Successfully made them available", + reply=message.tags["id"], + ) + conn.close() diff --git a/skgyorugo/commands/forcenothere.py b/skgyorugo/commands/forcenothere.py new file mode 100644 index 0000000..1b355d1 --- /dev/null +++ b/skgyorugo/commands/forcenothere.py @@ -0,0 +1,68 @@ +from aptbot.bot import Message, Commands, Bot +import os +import logging +import ttv_api.users +import sqlite3 +import time + +logger = logging.getLogger(__name__) +logger.setLevel(logging.DEBUG) + +formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") + +file_handler = logging.FileHandler("/var/log/aptbot/logs.log") +file_handler.setFormatter(formatter) + +logger.handlers = [] +logger.addHandler(file_handler) + +PERMISSION = 10 +PREFIX = "\\" +DESCRIPTION = r"Makes yourself temporarily unavailable in the list." +USER_COOLDOWN = 0 +GLOBAL_COOLDOWN = 0 + +PATH = os.path.dirname(os.path.realpath(__file__)) +PATH = os.path.join(PATH, "..") + + +def main(bot: Bot, message: Message): + twitch_name = message.tags.get("reply-parent-user-login", None) + if not twitch_name: + twitch_name = message.value.split(" ")[1] + twitch = ttv_api.users.get_users(user_logins=[twitch_name]) + if not twitch: + bot.send_privmsg( + message.channel, + "There was an issue fetching their twitch data. They weren't made unavailable.", + reply=message.tags["id"], + ) + return + twitch_id = twitch[0].user_id + conn = sqlite3.connect(os.path.join(PATH, "lol_data.db")) + c = conn.cursor() + + c.execute( + """ + UPDATE lol_queue SET available = 0, priority_queue = null, last_available = ? WHERE twitch_id = ?; + """, + ( + int(time.time()), + twitch_id, + ), + ) + if not c.rowcount: + bot.send_privmsg( + message.channel, + "They aren't in the list or they were already unavailable.", + reply=message.tags["id"], + ) + conn.close() + return + conn.commit() + bot.send_privmsg( + message.channel, + "Successfully made them unavailable", + reply=message.tags["id"], + ) + conn.close() diff --git a/skgyorugo/commands/forceunavailable.py b/skgyorugo/commands/forceunavailable.py deleted file mode 100644 index 1b355d1..0000000 --- a/skgyorugo/commands/forceunavailable.py +++ /dev/null @@ -1,68 +0,0 @@ -from aptbot.bot import Message, Commands, Bot -import os -import logging -import ttv_api.users -import sqlite3 -import time - -logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) - -PERMISSION = 10 -PREFIX = "\\" -DESCRIPTION = r"Makes yourself temporarily unavailable in the list." -USER_COOLDOWN = 0 -GLOBAL_COOLDOWN = 0 - -PATH = os.path.dirname(os.path.realpath(__file__)) -PATH = os.path.join(PATH, "..") - - -def main(bot: Bot, message: Message): - twitch_name = message.tags.get("reply-parent-user-login", None) - if not twitch_name: - twitch_name = message.value.split(" ")[1] - twitch = ttv_api.users.get_users(user_logins=[twitch_name]) - if not twitch: - bot.send_privmsg( - message.channel, - "There was an issue fetching their twitch data. They weren't made unavailable.", - reply=message.tags["id"], - ) - return - twitch_id = twitch[0].user_id - conn = sqlite3.connect(os.path.join(PATH, "lol_data.db")) - c = conn.cursor() - - c.execute( - """ - UPDATE lol_queue SET available = 0, priority_queue = null, last_available = ? WHERE twitch_id = ?; - """, - ( - int(time.time()), - twitch_id, - ), - ) - if not c.rowcount: - bot.send_privmsg( - message.channel, - "They aren't in the list or they were already unavailable.", - reply=message.tags["id"], - ) - conn.close() - return - conn.commit() - bot.send_privmsg( - message.channel, - "Successfully made them unavailable", - reply=message.tags["id"], - ) - conn.close() diff --git a/skgyorugo/commands/here.py b/skgyorugo/commands/here.py new file mode 100644 index 0000000..d64f6e3 --- /dev/null +++ b/skgyorugo/commands/here.py @@ -0,0 +1,260 @@ +from aptbot.bot import Message, Commands, Bot +import os +import logging +import ttv_api.users +import sqlite3 +import time + +logger = logging.getLogger(__name__) +logger.setLevel(logging.DEBUG) + +formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") + +file_handler = logging.FileHandler("/var/log/aptbot/logs.log") +file_handler.setFormatter(formatter) + +logger.handlers = [] +logger.addHandler(file_handler) + +PERMISSION = 99 +PREFIX = "?" +DESCRIPTION = r"Makes yourself available in the list." +USER_COOLDOWN = 600 +GLOBAL_COOLDOWN = 0 + +PATH = os.path.dirname(os.path.realpath(__file__)) +PATH = os.path.join(PATH, "..") + + +def main(bot: Bot, message: Message): + twitch = ttv_api.users.get_users(user_logins=[message.nick]) + if not twitch: + bot.send_privmsg( + message.channel, + "There was an issue fetching your twitch data. You weren't made unavailable.", + reply=message.tags["id"], + ) + return + twitch_id = twitch[0].user_id + conn = sqlite3.connect(os.path.join(PATH, "lol_data.db")) + c = conn.cursor() + + c.execute( + """ + UPDATE + lol_queue + SET + position = ( + CASE + WHEN ( + SELECT + position + FROM + lol_queue + WHERE + twitch_id = ? + ) < ( + SELECT + max(position) + FROM ( + SELECT + position + FROM + lol_queue + WHERE + available = 1 + ORDER BY + position + LIMIT ( + SELECT + data + FROM + lol_queue_data + WHERE + name = 'queuesize' + ) + ) + ) + THEN position + 1 + ELSE position + END + ) + WHERE + position > ( + SELECT + max(position) + FROM + lol_queue + WHERE + priority_queue = 1 + OR position <= ( + SELECT + max(position) + FROM ( + SELECT + position + FROM + lol_queue + WHERE + available = 1 + ORDER BY + position + LIMIT ( + SELECT + data + FROM + lol_queue_data + WHERE + name = 'queuesize' + ) + ) + + ) + ); + """, + (twitch_id,), + ) + + c.execute( + """ + UPDATE + lol_queue + SET + available = 1, + priority_queue = ( + CASE + WHEN ( + SELECT + position + FROM + lol_queue + WHERE + twitch_id = ? + ) < ( + SELECT + max(position) + FROM ( + SELECT + position + FROM + lol_queue + WHERE + available = 1 + ORDER BY + position + LIMIT ( + SELECT + data + FROM + lol_queue_data + WHERE + name = 'queuesize' + ) + ) + ) + THEN 1 + ELSE null + END + ), + position = ( + CASE + WHEN ( + SELECT + position + FROM + lol_queue + WHERE + twitch_id = ? + ) < ( + SELECT + max(position) + FROM ( + SELECT + position + FROM + lol_queue + WHERE + available = 1 + ORDER BY + position + LIMIT ( + SELECT + data + FROM + lol_queue_data + WHERE + name = 'queuesize' + ) + ) + ) + THEN 1 + ( + SELECT + max(position) + FROM + lol_queue + WHERE + priority_queue = 1 + OR position <= ( + SELECT + max(position) + FROM ( + SELECT + position + FROM + lol_queue + WHERE + available = 1 + ORDER BY + position + LIMIT ( + SELECT + data + FROM + lol_queue_data + WHERE + name = 'queuesize' + ) + ) + ) + ) + ELSE position + END + ), + time_remaining = time_remaining - (? - last_available) + WHERE + twitch_id = ? + AND available = 0; + """, + ( + twitch_id, + twitch_id, + int(time.time()), + twitch_id, + ), + ) + if c.rowcount < 1: + bot.send_privmsg( + message.channel, + "You aren't in the list or you were already available.", + reply=message.tags["id"], + ) + conn.close() + return + conn.commit() + c.execute("DELETE FROM lol_queue WHERE time_remaining < 0;") + if c.rowcount > 0: + bot.send_privmsg( + message.channel, + "You were unavailable for too long, you have been removed from the list.", + reply=message.tags["id"], + ) + conn.commit() + conn.close() + return + conn.commit() + bot.send_privmsg( + message.channel, + "Successfully made you available", + reply=message.tags["id"], + ) + conn.close() diff --git a/skgyorugo/commands/joke.py b/skgyorugo/commands/joke.py new file mode 100644 index 0000000..c01c1b2 --- /dev/null +++ b/skgyorugo/commands/joke.py @@ -0,0 +1,28 @@ +from aptbot.bot import Message, Commands, Bot +import tools.smart_privmsg +import urllib3 +import json + +PERMISSION = 99 +PREFIX = "?" +DESCRIPTION = r"" +USER_COOLDOWN = 30 +GLOBAL_COOLDOWN = 30 + +header = { + "Accept": "application/json", + "User-Agent": "For my twitch bot [MurphyAI] on https://twitch.tv/ihaspeks", +} + + +def main(bot: Bot, message: Message): + http = urllib3.PoolManager() + r = http.request("GET", "https://icanhazdadjoke.com", headers=header) + if r.status != 200: + tools.smart_privmsg.send( + bot, message, f"Couldn't get a joke Sadge", reply=message.tags["id"] + ) + return + + data = json.loads(r.data.decode("utf-8")) + tools.smart_privmsg.send(bot, message, f"{data['joke']}", reply=message.tags["id"]) diff --git a/skgyorugo/commands/nothere.py b/skgyorugo/commands/nothere.py new file mode 100644 index 0000000..9a2fb15 --- /dev/null +++ b/skgyorugo/commands/nothere.py @@ -0,0 +1,65 @@ +from aptbot.bot import Message, Commands, Bot +import os +import logging +import ttv_api.users +import sqlite3 +import time + +logger = logging.getLogger(__name__) +logger.setLevel(logging.DEBUG) + +formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") + +file_handler = logging.FileHandler("/var/log/aptbot/logs.log") +file_handler.setFormatter(formatter) + +logger.handlers = [] +logger.addHandler(file_handler) + +PERMISSION = 99 +PREFIX = "?" +DESCRIPTION = r"Makes yourself temporarily unavailable in the list." +USER_COOLDOWN = 10 +GLOBAL_COOLDOWN = 0 + +PATH = os.path.dirname(os.path.realpath(__file__)) +PATH = os.path.join(PATH, "..") + + +def main(bot: Bot, message: Message): + twitch = ttv_api.users.get_users(user_logins=[message.nick]) + if not twitch: + bot.send_privmsg( + message.channel, + "There was an issue fetching your twitch data. You weren't made unavailable.", + reply=message.tags["id"], + ) + return + twitch_id = twitch[0].user_id + conn = sqlite3.connect(os.path.join(PATH, "lol_data.db")) + c = conn.cursor() + + c.execute( + """ + UPDATE lol_queue SET available = 0, priority_queue = null, last_available = ? WHERE twitch_id = ?; + """, + ( + int(time.time()), + twitch_id, + ), + ) + if not c.rowcount: + bot.send_privmsg( + message.channel, + "You aren't in the list or you were already unavailable.", + reply=message.tags["id"], + ) + conn.close() + return + conn.commit() + bot.send_privmsg( + message.channel, + "Successfully made you unavailable", + reply=message.tags["id"], + ) + conn.close() diff --git a/skgyorugo/commands/unavailable.py b/skgyorugo/commands/unavailable.py deleted file mode 100644 index 9a2fb15..0000000 --- a/skgyorugo/commands/unavailable.py +++ /dev/null @@ -1,65 +0,0 @@ -from aptbot.bot import Message, Commands, Bot -import os -import logging -import ttv_api.users -import sqlite3 -import time - -logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -formatter = logging.Formatter("[%(levelname)s] %(asctime)s: %(name)s; %(message)s") - -file_handler = logging.FileHandler("/var/log/aptbot/logs.log") -file_handler.setFormatter(formatter) - -logger.handlers = [] -logger.addHandler(file_handler) - -PERMISSION = 99 -PREFIX = "?" -DESCRIPTION = r"Makes yourself temporarily unavailable in the list." -USER_COOLDOWN = 10 -GLOBAL_COOLDOWN = 0 - -PATH = os.path.dirname(os.path.realpath(__file__)) -PATH = os.path.join(PATH, "..") - - -def main(bot: Bot, message: Message): - twitch = ttv_api.users.get_users(user_logins=[message.nick]) - if not twitch: - bot.send_privmsg( - message.channel, - "There was an issue fetching your twitch data. You weren't made unavailable.", - reply=message.tags["id"], - ) - return - twitch_id = twitch[0].user_id - conn = sqlite3.connect(os.path.join(PATH, "lol_data.db")) - c = conn.cursor() - - c.execute( - """ - UPDATE lol_queue SET available = 0, priority_queue = null, last_available = ? WHERE twitch_id = ?; - """, - ( - int(time.time()), - twitch_id, - ), - ) - if not c.rowcount: - bot.send_privmsg( - message.channel, - "You aren't in the list or you were already unavailable.", - reply=message.tags["id"], - ) - conn.close() - return - conn.commit() - bot.send_privmsg( - message.channel, - "Successfully made you unavailable", - reply=message.tags["id"], - ) - conn.close()