From: Georgios Atheridis Date: Mon, 19 Sep 2022 16:55:58 +0000 (+0000) Subject: disabled jokes, changed timers X-Git-Url: https://git.atheridis.org/?a=commitdiff_plain;h=381d58891d1a993b5f4b285834e8093f6157fe53;p=ihaspeks%2Faptbot-ihaspeks.git disabled jokes, changed timers --- diff --git a/.gitignore b/.gitignore index 1e041e3..63a20b2 100644 --- a/.gitignore +++ b/.gitignore @@ -130,3 +130,4 @@ dmypy.json # sqlite databse *.db +data/ diff --git a/requirements.txt b/requirements.txt index c8ec5aa..fa45f51 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -aptbot @ git+https://github.com/atheridis/aptbot.git@296c2b730b342268c7b92725d9954fe9eef1ec12 +aptbot @ git+https://github.com/atheridis/aptbot.git@84683f404540292f74892576149e18a3d9d8fb61 python-dotenv==0.20.0 urllib3==1.26.11 diff --git a/skgyorugo/auto_messages/.jokes.py b/skgyorugo/auto_messages/.jokes.py new file mode 100644 index 0000000..a972958 --- /dev/null +++ b/skgyorugo/auto_messages/.jokes.py @@ -0,0 +1,26 @@ +from aptbot.bot import Message, Commands, Bot +import tools.smart_privmsg +import urllib3 +import json + +COOLDOWN = 30 * 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")) + joke = data["joke"].replace("\r\n", " ") + tools.smart_privmsg.send( + bot, message, f"{joke} ||| Get more jokes by typing ?joke" + ) diff --git a/skgyorugo/auto_messages/give_permission.py b/skgyorugo/auto_messages/give_permission.py new file mode 100644 index 0000000..f85bc9b --- /dev/null +++ b/skgyorugo/auto_messages/give_permission.py @@ -0,0 +1,15 @@ +from aptbot.bot import Message, Commands, Bot + +COOLDOWN = 60 * 60 +END_TIME = 0 + + +def main(bot: Bot, message: Message): + msg = "I collect data and occasionally post interesting statistics on peks' discord. " + msg += "The type of data you should expect to see is 'Chat frequency', 'Most used emotes', " + msg += "'Most active time and day', 'Reply graphs', etc. " + bot.send_privmsg(message.channel, msg) + + msg = "If you are okay with these stats being publicly available with your name, " + msg += "please type ?accept_share to let me know. " + bot.send_privmsg(message.channel, msg) diff --git a/skgyorugo/auto_messages/hello3.py b/skgyorugo/auto_messages/hello3.py index bbcee32..5f5a65d 100644 --- a/skgyorugo/auto_messages/hello3.py +++ b/skgyorugo/auto_messages/hello3.py @@ -1,7 +1,7 @@ from aptbot.bot import Message, Commands, Bot COOLDOWN = 30 * 60 -END_TIME = 2 * 60 * 60 +END_TIME = 1 * 60 * 60 def main(bot: Bot, message: Message): diff --git a/skgyorugo/auto_messages/jokes.py b/skgyorugo/auto_messages/jokes.py deleted file mode 100644 index bbb4eb8..0000000 --- a/skgyorugo/auto_messages/jokes.py +++ /dev/null @@ -1,26 +0,0 @@ -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")) - joke = data["joke"].replace("\r\n", " ") - tools.smart_privmsg.send( - bot, message, f"{joke} ||| Get more jokes by typing ?joke" - ) diff --git a/skgyorugo/auto_messages/latege.py b/skgyorugo/auto_messages/latege.py index 932f652..52fbf15 100644 --- a/skgyorugo/auto_messages/latege.py +++ b/skgyorugo/auto_messages/latege.py @@ -3,8 +3,8 @@ import datetime as dt from datetime import datetime import tools.smart_start_stream_time -COOLDOWN = 120 -END_TIME = COOLDOWN * 8 +COOLDOWN = 180 +END_TIME = COOLDOWN * 5 STREAM_SCHEDULE = dt.time(17, 30) diff --git a/skgyorugo/auto_messages/queuehelp.py b/skgyorugo/auto_messages/queuehelp.py index 473d550..1159e97 100644 --- a/skgyorugo/auto_messages/queuehelp.py +++ b/skgyorugo/auto_messages/queuehelp.py @@ -1,7 +1,7 @@ from aptbot.bot import Message, Commands, Bot -COOLDOWN = 8 * 60 -END_TIME = 2 * 60 * 60 +COOLDOWN = 30 * 60 +END_TIME = 2.5 * 60 * 60 def main(bot: Bot, message: Message): diff --git a/skgyorugo/auto_messages/youtube.py b/skgyorugo/auto_messages/youtube.py index 426f9fb..e71fa87 100644 --- a/skgyorugo/auto_messages/youtube.py +++ b/skgyorugo/auto_messages/youtube.py @@ -1,7 +1,7 @@ from aptbot.bot import Message, Commands, Bot import yt_api.videos -COOLDOWN = 25 * 60 +COOLDOWN = 30 * 60 END_TIME = 0 CHANNEL_ID = "UCQ7C3NUKY6TSkURdUdVoYFw" 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/accept_share.py b/skgyorugo/commands/accept_share.py new file mode 100644 index 0000000..80a7f6e --- /dev/null +++ b/skgyorugo/commands/accept_share.py @@ -0,0 +1,28 @@ +from aptbot.bot import Message, Commands, Bot +import tools.smart_privmsg +import os + +PERMISSION = 99 +PREFIX = "?" +DESCRIPTION = "" +USER_COOLDOWN = 30 +GLOBAL_COOLDOWN = 15 + + +COMMANDS_PATH = os.path.dirname(os.path.realpath(__file__)) +PATH = os.path.join(COMMANDS_PATH, "..") +DATA_PATH = os.path.join(PATH, "data") + + +def main(bot: Bot, message: Message): + accepted_path = os.path.join(DATA_PATH, "permission") + with open(accepted_path, "r") as f: + accepted = [user_id.rstrip() for user_id in f] + if message.tags["user-id"] in accepted: + tools.smart_privmsg.send(bot, message, "You have already given permission") + return + + with open(accepted_path, "a") as f: + f.write(f"{message.tags['user-id']}\n") + tools.smart_privmsg.send(bot, message, "Thank you for giving permission") + diff --git a/skgyorugo/commands/joke.py b/skgyorugo/commands/joke.py deleted file mode 100644 index c01c1b2..0000000 --- a/skgyorugo/commands/joke.py +++ /dev/null @@ -1,28 +0,0 @@ -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/truth.py b/skgyorugo/commands/truth.py new file mode 100644 index 0000000..ad38954 --- /dev/null +++ b/skgyorugo/commands/truth.py @@ -0,0 +1,24 @@ +from aptbot.bot import Message, Commands, Bot +import tools.smart_privmsg +import os +import random + +PERMISSION = 99 +PREFIX = "?" +DESCRIPTION = "" +USER_COOLDOWN = 30 +GLOBAL_COOLDOWN = 15 + + +COMMANDS_PATH = os.path.dirname(os.path.realpath(__file__)) +PATH = os.path.join(COMMANDS_PATH, "..") +DATA_PATH = os.path.join(PATH, "data") + + +def main(bot: Bot, message: Message): + 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"])