Skip to content

Commit

Permalink
Merge pull request #2 from aadi-1024/main
Browse files Browse the repository at this point in the history
Progess on bot with python
  • Loading branch information
aadi-1024 authored Feb 1, 2023
2 parents 2eccf28 + ba6f2e9 commit 1642820
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.env
node_modules/
.vscode/
Aaditya/.env
28 changes: 28 additions & 0 deletions Aaditya/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import discord

class Client(discord.Client):
async def on_ready(self):
print("Bot is online!")

async def on_message(self, message):
if message.author == self.user:
return
if message.content.startswith("!hi"):
await message.channel.send(f"Hi! {message.author.mention}")
elif message.content.startswith("!search"):
x = ' '.join(message.content.split()[1:])
print(x) #TODO

def main():
#only works if command is invoked from the working directory itself
with open(".env", "r") as file:
token = file.readline()

intent = discord.Intents.default()
intent.message_content = True

client = Client(intents=intent)
client.run(token)

if __name__ == "__main__":
main()
21 changes: 21 additions & 0 deletions Aaditya/scrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#adjusting code from ./Adamay/TwitterScrapper_boi.ipynb to use with the bot

import snscrape.modules.twitter as sntwitter
import pandas as pd

class Scraper:
def __init__(self):
pass
def scrape(text):
fQuery=text+' min_faves:4000'
data=sntwitter.TwitterSearchScraper(fQuery)
tweets=[]

for i,tweet in enumerate(data.get_items()):
data1=[tweet.url,tweet.user.username,tweet.rawContent]
tweets.append(data1)
if i>50:
break

fData=pd.DataFrame(tweets,columns='Link Username Content'.split())
#TODO

0 comments on commit 1642820

Please sign in to comment.