working kwaylon

This commit is contained in:
jsl12
2022-01-21 17:19:11 -06:00
parent 2d65987306
commit 3b32e6b396
6 changed files with 37 additions and 36 deletions

View File

@@ -5,13 +5,10 @@ RUN python -m pip install --upgrade pip
RUN pip install pandas RUN pip install pandas
RUN pip install discord.py RUN pip install discord.py
RUN pip install nltk RUN pip install nltk
RUN python -m nltk.downloader -d /usr/local/share/nltk_data all
# below fuckery from stockquotes RUN pip install python-dotenv
RUN pip install beautifulsoup4
RUN pip install requests
WORKDIR /usr/src/app WORKDIR /usr/src/app
COPY ./ ./ COPY ./ ./
RUN pip install -r requirements.txt
CMD [ "python", "main.py" ] CMD [ "python", "main.py" ]

View File

@@ -8,5 +8,4 @@ services:
volumes: volumes:
- /etc/localtime:/etc/localtime:ro - /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro - /etc/timezone:/etc/timezone:ro
# - /mnt/dietpi_userdata/kwaylon:/usr/src/app
restart: unless-stopped restart: unless-stopped

View File

@@ -1,7 +1,7 @@
import re import re
import discord import discord
import stockquotes # import stockquotes
from . import base, helpers from . import base, helpers
@@ -64,17 +64,18 @@ class AssJoke(base.Joke):
await message.reply(f'{res} {discord.utils.get(client.emojis, name="kaylon")}') await message.reply(f'{res} {discord.utils.get(client.emojis, name="kaylon")}')
class DominosJoke(base.Joke): # DominosJoke isn't working because stockquotes is fucked
@property # class DominosJoke(base.Joke):
def regex(self) -> re.Pattern: # @property
return re.compile('domino\'?s', re.IGNORECASE) # def regex(self) -> re.Pattern:
# return re.compile('domino\'?s', re.IGNORECASE)
async def respond(self, message: discord.Message, client: discord.Client, match: re.Match): #
cp = stockquotes.Stock('DPZ').current_price # async def respond(self, message: discord.Message, client: discord.Client, match: re.Match):
msg = f'You know, my friend Ben has made about ${cp - 16:.0f} on Domino\'s stock. He basically owns it now' # cp = stockquotes.Stock('DPZ').current_price
if (e := discord.utils.get(client.emojis, name="pizza")): # msg = f'You know, my friend Ben has made about ${cp - 16:.0f} on Domino\'s stock. He basically owns it now'
await message.add_reaction(e) # if (e := discord.utils.get(client.emojis, name="pizza")):
await message.reply(msg) # await message.add_reaction(e)
# await message.reply(msg)
class BeansJoke(base.GifJoke): class BeansJoke(base.GifJoke):

View File

@@ -33,12 +33,14 @@ class Kwaylon(discord.Client):
async def handle_ready(self): async def handle_ready(self):
async def alive(): async def alive():
channel: discord.TextChannel = discord.utils.get(self.get_all_channels(), name='robotics-facility') channel: discord.TextChannel = discord.utils.get(self.get_all_channels(), name='robotics-facility')
await channel.send(f"I'm aliiiiiive {discord.utils.get(self.emojis, name='kaylon')}") await channel.send('https://tenor.com/view/terminator-im-back-gif-19144173')
await channel.send(f"{discord.utils.get(self.emojis, name='kaylon')}")
self.data: data.MsgData = await data.MsgData.create(client=self, limit=self.limit, days=self.days) await alive()
self.data.to_sql(self.db_path)
LOGGER.info(f'{self.data.msgs.shape[0]} messages total') # self.data: data.MsgData = await data.MsgData.create(client=self, limit=self.limit, days=self.days)
# await alive() # self.data.to_sql(self.db_path)
# LOGGER.info(f'{self.data.msgs.shape[0]} messages total')
async def handle_message(self, message): async def handle_message(self, message):
if message.author != self.user: if message.author != self.user:

16
main.py
View File

@@ -27,14 +27,14 @@ if __name__ == '__main__':
await client.handle_message(message) await client.handle_message(message)
@client.event # @client.event
async def on_raw_reaction_add(payload: RawReactionActionEvent): # async def on_raw_reaction_add(payload: RawReactionActionEvent):
await client.handle_raw_reaction(payload) # await client.handle_raw_reaction(payload)
#
#
@client.event # @client.event
async def on_raw_reaction_remove(payload: RawReactionActionEvent): # async def on_raw_reaction_remove(payload: RawReactionActionEvent):
await client.handle_raw_reaction(payload) # await client.handle_raw_reaction(payload)
load_dotenv() load_dotenv()

View File

@@ -1,8 +1,10 @@
python-dotenv pandas
discord.py discord.py
# nextcord # nextcord
pandas
nltk nltk
beautifulsoup4 python-dotenv
requests
stockquotes # stockquotes
# beautifulsoup4
# requests
# lxml