-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from aadi-1024/main
Progess on bot with python
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
.env | ||
node_modules/ | ||
.vscode/ | ||
Aaditya/.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |