diff --git a/Aaditya/config b/Aaditya/config index 537984b..309bcd8 100644 --- a/Aaditya/config +++ b/Aaditya/config @@ -1,4 +1,5 @@ -likes=50000 -num=1 -sdate=2022-02-01 -ldate=2022-02-18 +likes=1000 +num=5 +sdate=2023-01-01 +ldate=2023-02-17 +prefix=$ diff --git a/Aaditya/main.py b/Aaditya/main.py index 5b3fe65..34023a9 100644 --- a/Aaditya/main.py +++ b/Aaditya/main.py @@ -9,15 +9,16 @@ async def on_ready(self): print("Bot is online!") self.scraper = Scraper() self.config = Config('config') + self.prefix = self.config.val('prefix') async def on_message(self, message): if message.author == self.user: return - if message.content.startswith("!hi"): + if message.content.startswith(f'{self.prefix}hi'): await message.channel.send(f"Hi! {message.author.mention}") - elif message.content.startswith("!search"): + elif message.content.startswith(f'{self.prefix}search'): x = ' '.join(message.content.split()[1:]) await message.channel.send(f"Looking up twitter for {x}") @@ -37,7 +38,7 @@ async def on_message(self, message): await message.channel.send(embed=discord.Embed(color=discord.Colour.blurple(), title=x, description=desc)) - elif message.content.startswith('!setlikes'): + elif message.content.startswith(f'{self.prefix}setlikes'): try: x = int(message.content.split()[1]) self.config.update('likes', x) @@ -45,7 +46,7 @@ async def on_message(self, message): except: await message.channel.send("Please enter an integer value") - elif message.content.startswith('!setnum'): + elif message.content.startswith(f'{self.prefix}setnum'): try: x = int(message.content.split()[1]) @@ -54,15 +55,33 @@ async def on_message(self, message): except: await message.channel.send("Please enter an integer value") - elif message.content.startswith('!sdate'): + elif message.content.startswith(f'{self.prefix}date'): x = message.content.split()[1] + y = message.content.split()[2] self.config.update('sdate', x) - await message.channel.send(f"Done! Only Tweets made after {x} will be shown") - - elif message.content.startswith('!ldate'): + self.config.update('ldate', y) + await message.channel.send(f"Done! Only Tweets made after {x} and before {y} will be shown") + + elif message.content.startswith(f'{self.prefix}prefix'): x = message.content.split()[1] - self.config.update('ldate', x) - await message.channel.send(f"Done! Only Tweets made before {x} will be shown") + self.prefix = x + self.config.update('prefix', x) + await message.channel.send(f'Success! Prefix has been updated to **{x}**') + + elif message.content.startswith(f'{self.prefix}help'): + desc = f""" + **List of Commands** + 1. **{self.prefix}search**: Search Twitter for anything + 2. **{self.prefix}hi**: Hi :) + 3. **{self.prefix}setlikes**: Set minimum likes for tweets to have + 4. **{self.prefix}setnum**: Set number of tweets to show + 5. **{self.prefix}date**: Set date range of tweets. Use YYYY-MM-DD format + 6. **{self.prefix}prefix**: Set the prefix for the bot + 7. **{self.prefix}help**: This command + + **The prefix for the bot is set to {self.prefix}** + """ + await message.channel.send(embed=discord.Embed(color=discord.Colour.blurple(), title="Commands", description=desc)) def main(): # only works if command is invoked from the working directory itself