From 381d58891d1a993b5f4b285834e8093f6157fe53 Mon Sep 17 00:00:00 2001 From: Georgios Atheridis Date: Mon, 19 Sep 2022 16:55:58 +0000 Subject: [PATCH] disabled jokes, changed timers --- .gitignore | 1 + requirements.txt | 2 +- .../auto_messages/{jokes.py => .jokes.py} | 2 +- skgyorugo/auto_messages/give_permission.py | 15 ++++++++++ skgyorugo/auto_messages/hello3.py | 2 +- skgyorugo/auto_messages/latege.py | 4 +-- skgyorugo/auto_messages/queuehelp.py | 4 +-- skgyorugo/auto_messages/youtube.py | 2 +- skgyorugo/commands/{joke.py => .joke.py} | 0 skgyorugo/commands/accept_share.py | 28 +++++++++++++++++++ skgyorugo/commands/truth.py | 24 ++++++++++++++++ 11 files changed, 76 insertions(+), 8 deletions(-) rename skgyorugo/auto_messages/{jokes.py => .jokes.py} (97%) create mode 100644 skgyorugo/auto_messages/give_permission.py rename skgyorugo/commands/{joke.py => .joke.py} (100%) create mode 100644 skgyorugo/commands/accept_share.py create mode 100644 skgyorugo/commands/truth.py 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 similarity index 97% rename from skgyorugo/auto_messages/jokes.py rename to skgyorugo/auto_messages/.jokes.py index bbb4eb8..a972958 100644 --- a/skgyorugo/auto_messages/jokes.py +++ b/skgyorugo/auto_messages/.jokes.py @@ -3,7 +3,7 @@ import tools.smart_privmsg import urllib3 import json -COOLDOWN = 20 * 60 +COOLDOWN = 30 * 60 END_TIME = 0 header = { 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/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 similarity index 100% rename from skgyorugo/commands/joke.py rename to skgyorugo/commands/.joke.py 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/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"]) -- 2.30.2