WillieTimer Update

WillieTimer: Added a Phrases.txt for random 4:20 selection
WillieTimer: Updated cog.py to use Phrases.txt
Update gitignore
This commit is contained in:
Logan Cusano
2021-12-18 04:06:45 -05:00
parent 31758b0c2d
commit e7006cd40a
3 changed files with 25 additions and 10 deletions

5
.gitignore vendored
View File

@@ -1,4 +1,7 @@
/.idea/
/__pycache__/
/venv/
config.ini
config.ini
*.7z
*.bat
/DSDPlus/

View File

@@ -0,0 +1,10 @@
Hey, are you busy? I just wanted to let you know IT'S 4:20!
You know, the funny thing about time is we often forget to pay attention to it and we miss out on things. ALMOST LIKE 4:20! LIGHT UP!
Oh say can you see. By the blunts early light. IT'S 4:20!
Can you smell what the rock is cooking? No? PROBABLY BECAUSE IT'S 4:20!
Willie wanted to let you know that IT'S 4:20!
It's 4:20! It's time to light up!
4:20. Can you stand it? Wait, that's not right. IT'S 4:20!!
smoke on 4/20 inhale with friends at Lowlife, Red Tiger, Taraval, Buddha Lounge, and Sticky Rice
4:20! Well, I'll take a hit. Why not! Isn't this the right way to think about time. I mean, hey, we're at 4:20 in the afternoon today, so it must make sense to think of 4:20 as THE RIGHT TIME TO FLIP A CIGARETTE!
(I'll now take a moment to explain to you what 4:20 actually means.)

View File

@@ -1,5 +1,6 @@
import asyncio
import datetime
import random
import discord
from random import choice
from discord.ext import commands
@@ -13,14 +14,6 @@ class WillieTimer(commands.Cog):
self.mention_group = str(self.bot.Default_Mention_Group)
self.channel_id = int(self.bot.Default_Channel_ID)
self.lock = False
self.message_pool = [
"It's 4:20! It's time to light up!",
"Willie wanted to let you know that IT'S 4:20!",
"Can you smell what the rock is cooking? No? PROBABLY BECAUSE IT'S 4:20!",
"Oh say can you see. By the blunts early light. IT'S 4:20!",
"Hey, are you busy? I just wanted to let you know IT'S 4:20!",
"You know, the funny thing about time is we often forget to pay attention to it and we miss out on things. ALMOST LIKE 4:20! LIGHT UP!"
]
@loop(minutes=1)
async def bg_timer(self):
@@ -31,7 +24,7 @@ class WillieTimer(commands.Cog):
if datetime.datetime.now().strftime('%H:%M') in ("04:20", "16:20"):
print(f"It's {datetime.datetime.now().strftime('%H:%M:%S')}!")
channel = self.bot.get_channel(id=self.channel_id)
await channel.send(f"<@&{self.bot_get_role().id}> {choice(self.message_pool)}")
await channel.send(f"<@&{self.bot_get_role().id}> {self.get_random_phrase()}")
@commands.command(help="Use this command to start the background task to wait for 4:20",
brief="Starts the 4:20 clock")
@@ -93,6 +86,15 @@ class WillieTimer(commands.Cog):
role = discord.utils.get(guild.roles, name=self.mention_group)
return role
def get_random_phrase(self):
selected_phrase = None
with open('./Phrases.txt', 'r') as phrase_file:
phrases = phrase_file.readlines()
selected_phrase = choice(phrases)
if selected_phrase is not None:
return selected_phrase
def setup(bot: commands.Bot):
bot.add_cog(WillieTimer(bot))