From f4a4f915d81d109899014267a1babafbe3608aa0 Mon Sep 17 00:00:00 2001 From: loganv22 <92587557+loganv22@users.noreply.github.com> Date: Sat, 19 Feb 2022 18:38:36 +0000 Subject: [PATCH 1/6] added Heroku setup --- Procfile | 1 + main.py | 8 ++-- requirements.txt | 117 +++++++++++++++++++++++++++++++++++++++++++++++ runtime.txt | 1 + 4 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 Procfile create mode 100644 requirements.txt create mode 100644 runtime.txt diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..c445cb1 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +worker: python3 main.py \ No newline at end of file diff --git a/main.py b/main.py index a8f8729..46bde41 100644 --- a/main.py +++ b/main.py @@ -54,22 +54,22 @@ async def on_message(message): if len(insultRequest) > 1 and insultRequest[1].startswith("<@"): await message.channel.send(u.randomYourMomJoke(insultRequest[1])) if random.randrange(100) > 100 - int(u.textRead("settings.txt")[2]): - await message.channel.send(file=discord.File('insults/roastedgifs/roasted'+str(random.randint(1, 4))+ '.gif')) + await message.channel.send(file=discord.File('insults/roastedgifs/roasted'+str(random.randint(1, 5))+ '.gif')) else: await message.channel.send(u.randomYourMomJoke()) if random.randrange(100) > 100 - int(u.textRead("settings.txt")[2]): - await message.channel.send(file=discord.File('insults/roastedgifs/roasted'+str(random.randint(1, 4))+ '.gif')) + await message.channel.send(file=discord.File('insults/roastedgifs/roasted'+str(random.randint(1, 5))+ '.gif')) return elif message.content.startswith(prefix + "geninsult"): insultRequest = message.content.split(" ") if len(insultRequest) > 1 and insultRequest[1].startswith("<@"): await message.channel.send(u.generateYourMomJoke(insultRequest[1])) if random.randrange(100) > 100 - int(u.textRead("settings.txt")[2]): - await message.channel.send(file=discord.File('insults/roastedgifs/roasted'+str(random.randint(1, 4))+ '.gif')) + await message.channel.send(file=discord.File('insults/roastedgifs/roasted'+str(random.randint(1, 5))+ '.gif')) else: await message.channel.send(u.generateYourMomJoke()) if random.randrange(100) > 100 - int(u.textRead("settings.txt")[2]): - await message.channel.send(file=discord.File('insults/roastedgifs/roasted'+str(random.randint(1, 4))+ '.gif')) + await message.channel.send(file=discord.File('insults/roastedgifs/roasted'+str(random.randint(1, 5))+ '.gif')) return elif message.content.startswith(prefix + "help"): await message.channel.send(f""" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..eff45eb --- /dev/null +++ b/requirements.txt @@ -0,0 +1,117 @@ +absl-py==0.13.0 +aiohttp==3.7.4.post0 +antlr4-python3-runtime==4.9.2 +astunparse==1.6.3 +async-timeout==3.0.1 +attrs==21.2.0 +backports.entry-points-selectable==1.1.0 +CacheControl==0.12.6 +cachetools==4.2.2 +cachy==0.3.0 +certifi==2021.5.30 +cffi==1.14.6 +chardet==4.0.0 +charset-normalizer==2.0.4 +cleo==0.8.1 +click==8.0.1 +clikit==0.6.2 +crashtest==0.3.1 +cryptography==3.4.8 +cs50==7.0.2 +cycler==0.10.0 +debugpy==1.2.1 +distlib==0.3.2 +docopt==0.6.2 +filelock==3.0.12 +Flask==2.0.1 +funcsigs==1.0.2 +future==0.18.2 +gast==0.3.3 +glfw==2.2.0 +google-auth==1.35.0 +google-auth-oauthlib==0.4.6 +google-pasta==0.2.0 +greenlet==1.1.1 +grpcio==1.40.0 +h5py==2.10.0 +html5lib==1.1 +idna==3.2 +importlib-metadata==3.10.1 +itsdangerous==2.0.1 +jedi==0.15.2 +jeepney==0.7.1 +Jinja2==3.0.1 +joblib==1.0.1 +Keras-Preprocessing==1.1.2 +keyring==21.8.0 +kiwisolver==1.3.2 +lockfile==0.12.2 +Markdown==3.3.4 +MarkupSafe==2.0.1 +matplotlib==3.4.3 +msgpack==1.0.2 +multidict==5.1.0 +nltk==3.6.2 +numpy==1.21.2 +oauthlib==3.1.1 +opt-einsum==3.3.0 +packaging==20.9 +parso==0.5.2 +pastel==0.2.1 +pexpect==4.8.0 +Pillow==8.3.2 +pipreqs-amasad==0.4.10 +pkginfo==1.7.1 +platformdirs==2.3.0 +pluggy==0.13.1 +poetry==1.1.6 +poetry-core==1.0.4 +protobuf==3.17.3 +ptyprocess==0.7.0 +pyasn1==0.4.8 +pyasn1-modules==0.2.8 +pycparser==2.20 +pyflakes==2.1.1 +pygame==2.0.1 +pylev==1.4.0 +PyOpenGL==3.1.5 +pyparsing==2.4.7 +pyquil==1.9.0 +python-dateutil==2.8.2 +python-jsonrpc-server==0.3.2 +python-language-server==0.31.10 +pyxel @ git+https://github.com/amasad/pyxel@8bcc2266b2fbb65f72ad686952de3838971c136e +referenceqvm==0.3 +regex==2021.8.28 +replit==3.2.4 +requests==2.26.0 +requests-oauthlib==1.3.0 +requests-toolbelt==0.9.1 +rope==0.18.0 +rsa==4.7.2 +scipy==1.4.1 +SecretStorage==3.3.1 +shellingham==1.4.0 +six==1.16.0 +sounddevice==0.4.2 +SQLAlchemy==1.4.23 +sqlparse==0.4.2 +tensorboard==2.2.2 +tensorboard-plugin-wit==1.8.0 +tensorflow-cpu @ https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.2.0-cp38-cp38-manylinux2010_x86_64.whl +tensorflow-estimator==2.2.0 +termcolor==1.1.0 +toml==0.10.2 +tomlkit==0.7.2 +tqdm==4.62.2 +typing-extensions==3.7.4.3 +ujson==1.35 +urllib3==1.26.6 +virtualenv==20.7.2 +webencodings==0.5.1 +Werkzeug==2.0.1 +wrapt==1.12.1 +yapf==0.31.0 +yarg==0.1.9 +yarl==1.6.3 +zipp==3.4.1 \ No newline at end of file diff --git a/runtime.txt b/runtime.txt new file mode 100644 index 0000000..946d2ad --- /dev/null +++ b/runtime.txt @@ -0,0 +1 @@ +python-3.8.12 \ No newline at end of file From 4fc3cb1451914ac1d62c8695fe636f97cc70bd0c Mon Sep 17 00:00:00 2001 From: loganv22 <92587557+loganv22@users.noreply.github.com> Date: Sat, 19 Feb 2022 18:40:50 +0000 Subject: [PATCH 2/6] settings adjusted --- settings.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/settings.txt b/settings.txt index 6998449..3161aab 100644 --- a/settings.txt +++ b/settings.txt @@ -1,4 +1,4 @@ 100 -5 -100 -! \ No newline at end of file +10 +20 +ree! \ No newline at end of file From 1b7e6fefbe57b944bf1f74c03c5321e8befdb3da Mon Sep 17 00:00:00 2001 From: loganv22 <92587557+loganv22@users.noreply.github.com> Date: Sat, 19 Feb 2022 20:03:42 +0000 Subject: [PATCH 3/6] it works this way w uptime robot so if it ain't broke don't fix it --- Procfile | 1 - requirements.txt | 117 ----------------------------------------------- runtime.txt | 1 - 3 files changed, 119 deletions(-) delete mode 100644 Procfile delete mode 100644 requirements.txt delete mode 100644 runtime.txt diff --git a/Procfile b/Procfile deleted file mode 100644 index c445cb1..0000000 --- a/Procfile +++ /dev/null @@ -1 +0,0 @@ -worker: python3 main.py \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index eff45eb..0000000 --- a/requirements.txt +++ /dev/null @@ -1,117 +0,0 @@ -absl-py==0.13.0 -aiohttp==3.7.4.post0 -antlr4-python3-runtime==4.9.2 -astunparse==1.6.3 -async-timeout==3.0.1 -attrs==21.2.0 -backports.entry-points-selectable==1.1.0 -CacheControl==0.12.6 -cachetools==4.2.2 -cachy==0.3.0 -certifi==2021.5.30 -cffi==1.14.6 -chardet==4.0.0 -charset-normalizer==2.0.4 -cleo==0.8.1 -click==8.0.1 -clikit==0.6.2 -crashtest==0.3.1 -cryptography==3.4.8 -cs50==7.0.2 -cycler==0.10.0 -debugpy==1.2.1 -distlib==0.3.2 -docopt==0.6.2 -filelock==3.0.12 -Flask==2.0.1 -funcsigs==1.0.2 -future==0.18.2 -gast==0.3.3 -glfw==2.2.0 -google-auth==1.35.0 -google-auth-oauthlib==0.4.6 -google-pasta==0.2.0 -greenlet==1.1.1 -grpcio==1.40.0 -h5py==2.10.0 -html5lib==1.1 -idna==3.2 -importlib-metadata==3.10.1 -itsdangerous==2.0.1 -jedi==0.15.2 -jeepney==0.7.1 -Jinja2==3.0.1 -joblib==1.0.1 -Keras-Preprocessing==1.1.2 -keyring==21.8.0 -kiwisolver==1.3.2 -lockfile==0.12.2 -Markdown==3.3.4 -MarkupSafe==2.0.1 -matplotlib==3.4.3 -msgpack==1.0.2 -multidict==5.1.0 -nltk==3.6.2 -numpy==1.21.2 -oauthlib==3.1.1 -opt-einsum==3.3.0 -packaging==20.9 -parso==0.5.2 -pastel==0.2.1 -pexpect==4.8.0 -Pillow==8.3.2 -pipreqs-amasad==0.4.10 -pkginfo==1.7.1 -platformdirs==2.3.0 -pluggy==0.13.1 -poetry==1.1.6 -poetry-core==1.0.4 -protobuf==3.17.3 -ptyprocess==0.7.0 -pyasn1==0.4.8 -pyasn1-modules==0.2.8 -pycparser==2.20 -pyflakes==2.1.1 -pygame==2.0.1 -pylev==1.4.0 -PyOpenGL==3.1.5 -pyparsing==2.4.7 -pyquil==1.9.0 -python-dateutil==2.8.2 -python-jsonrpc-server==0.3.2 -python-language-server==0.31.10 -pyxel @ git+https://github.com/amasad/pyxel@8bcc2266b2fbb65f72ad686952de3838971c136e -referenceqvm==0.3 -regex==2021.8.28 -replit==3.2.4 -requests==2.26.0 -requests-oauthlib==1.3.0 -requests-toolbelt==0.9.1 -rope==0.18.0 -rsa==4.7.2 -scipy==1.4.1 -SecretStorage==3.3.1 -shellingham==1.4.0 -six==1.16.0 -sounddevice==0.4.2 -SQLAlchemy==1.4.23 -sqlparse==0.4.2 -tensorboard==2.2.2 -tensorboard-plugin-wit==1.8.0 -tensorflow-cpu @ https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.2.0-cp38-cp38-manylinux2010_x86_64.whl -tensorflow-estimator==2.2.0 -termcolor==1.1.0 -toml==0.10.2 -tomlkit==0.7.2 -tqdm==4.62.2 -typing-extensions==3.7.4.3 -ujson==1.35 -urllib3==1.26.6 -virtualenv==20.7.2 -webencodings==0.5.1 -Werkzeug==2.0.1 -wrapt==1.12.1 -yapf==0.31.0 -yarg==0.1.9 -yarl==1.6.3 -zipp==3.4.1 \ No newline at end of file diff --git a/runtime.txt b/runtime.txt deleted file mode 100644 index 946d2ad..0000000 --- a/runtime.txt +++ /dev/null @@ -1 +0,0 @@ -python-3.8.12 \ No newline at end of file From 97a65392e4d585bc325f45d9c0a3b7f029e77dec Mon Sep 17 00:00:00 2001 From: loganv22 <92587557+loganv22@users.noreply.github.com> Date: Sat, 19 Feb 2022 15:46:26 -0500 Subject: [PATCH 4/6] Update util.py --- util.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/util.py b/util.py index 4d98fa6..04f6648 100644 --- a/util.py +++ b/util.py @@ -1,11 +1,13 @@ import random +# checks messages def containsAny(searchIn, strings): searchIn = searchIn.lower() for i in strings: if i in searchIn: return i return None +# turns file into list def textRead(fname): with open(fname) as f: fList = f.readlines() @@ -13,6 +15,7 @@ def textRead(fname): fList[i] = fList[i].strip("\n") return fList +# selects random joke from list def randomYourMomJoke(victim=""): insultList = textRead("insults/yourMom.txt") @@ -21,15 +24,17 @@ def randomYourMomJoke(victim=""): else: return "Hey " + victim + ", " + random.choice(insultList) +# creates a random joke that usually makes no sense def generateYourMomJoke(victim=""): verb = random.choice(textRead("insults/verbs.txt")) noun = random.choice(textRead("insults/nouns.txt")) adj = random.choice(textRead("insults/adjectives.txt")) joke_format = random.choice(textRead("insults/jokeTemplates.txt")) + # creates joke from random template and random words insult = joke_format.format(verb = verb, noun = noun, adjective = adj) if victim == "": return insult else: - return "Hey " + victim + ", " + insult \ No newline at end of file + return "Hey " + victim + ", " + insult From 5437739fe6d4e27d277b62ad996198052176fd04 Mon Sep 17 00:00:00 2001 From: loganv22 <92587557+loganv22@users.noreply.github.com> Date: Sat, 19 Feb 2022 15:46:51 -0500 Subject: [PATCH 5/6] Delete todo.md --- todo.md | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 todo.md diff --git a/todo.md b/todo.md deleted file mode 100644 index 59936ae..0000000 --- a/todo.md +++ /dev/null @@ -1,4 +0,0 @@ -help menu that includes: - - change the prefix(maybe) - - change frequency of animal responses - - change frequency of misc responses \ No newline at end of file From be09e1af57c1eb81222b323addc4c9c951bad611 Mon Sep 17 00:00:00 2001 From: loganv22 <92587557+loganv22@users.noreply.github.com> Date: Sat, 19 Feb 2022 16:43:53 -0500 Subject: [PATCH 6/6] Update main.py --- main.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index 46bde41..5fc275b 100644 --- a/main.py +++ b/main.py @@ -2,19 +2,19 @@ import os import random import util as u -from keep_alive import keep_alive +from keep_alive import keep_alive # as one might guess, this keeps the bot running import discord from dotenv import load_dotenv -# fancy tech stuff - gets the secrets +# fancy tech stuff - gets the secrets from the repl where it runs load_dotenv() TOKEN = os.getenv('DISCORD_TOKEN') # useful variables prefix = u.textRead("settings.txt")[3] client = discord.Client() -rps = False +rps = False # enables rock paper scissors game # displays when bot connects @client.event @@ -25,8 +25,11 @@ async def on_ready(): async def on_message(message): global rps + # makes sure the bot doesn't activate itself if message.author == client.user: return + + # rock paper scissors if message.content.startswith(prefix + "rps"): await message.channel.send("Ok let's play. You go first.") rps = True @@ -49,17 +52,20 @@ async def on_message(message): rps = False return + # pulls from a list of yo mama jokes if message.content.startswith(prefix + "insult"): insultRequest = message.content.split(" ") - if len(insultRequest) > 1 and insultRequest[1].startswith("<@"): - await message.channel.send(u.randomYourMomJoke(insultRequest[1])) + if len(insultRequest) > 2 and insultRequest[2].startswith("<@"): + await message.channel.send(u.randomYourMomJoke(insultRequest[2])) if random.randrange(100) > 100 - int(u.textRead("settings.txt")[2]): - await message.channel.send(file=discord.File('insults/roastedgifs/roasted'+str(random.randint(1, 5))+ '.gif')) + await message.channel.send(file=discord.File('insults/roastedgifs/roasted'+str(random.randint(1, 5))+ '.gif')) # chance to send a gif else: await message.channel.send(u.randomYourMomJoke()) if random.randrange(100) > 100 - int(u.textRead("settings.txt")[2]): - await message.channel.send(file=discord.File('insults/roastedgifs/roasted'+str(random.randint(1, 5))+ '.gif')) + await message.channel.send(file=discord.File('insults/roastedgifs/roasted'+str(random.randint(1, 5))+ '.gif')) # chance to send a gif return + + # randomly generated yo mama joke elif message.content.startswith(prefix + "geninsult"): insultRequest = message.content.split(" ") if len(insultRequest) > 1 and insultRequest[1].startswith("<@"): @@ -71,6 +77,8 @@ async def on_message(message): if random.randrange(100) > 100 - int(u.textRead("settings.txt")[2]): await message.channel.send(file=discord.File('insults/roastedgifs/roasted'+str(random.randint(1, 5))+ '.gif')) return + + # explains the bot elif message.content.startswith(prefix + "help"): await message.channel.send(f""" Hello! I'm a very accurate representation of an annoying adolescent, created by a group of annoying adolescents. I tell the best your mom jokes you've ever encountered. Try some of these commands! @@ -95,17 +103,19 @@ async def on_message(message): Curse another Discord server with my presence! https://discord.com/api/oauth2/authorize?client_id=944652303632322591&permissions=277025459264&redirect_uri=https%3A%2F%2Fdiscord.com%2Fchannels%2F%40me&response_type=code&scope=bot%20messages.read -*I'm dedicated to ZA!* You know what you said about my mother. +*I'm dedicated to ZA! You know what you said about my mother.* *This is a submission for Hack Kean 2022* """) return + # responds to any animal mentions with a rude comparison to your mother animal = u.containsAny(message.content, u.textRead("insults/animals.txt")) if random.randrange(100) > 100 - int(u.textRead("settings.txt")[0]) and animal: await message.channel.send(f'{animal.title()}? Like your mom?') return + # random snarky comments if random.randrange(100) > 100 - int(u.textRead("settings.txt")[1]): if ( message.content.lower().startswith("who ") or @@ -133,4 +143,4 @@ async def on_message(message): return keep_alive() -client.run(TOKEN) \ No newline at end of file +client.run(TOKEN)