Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.env
.env
.vscode/launch.json
.DS_Store
66 changes: 43 additions & 23 deletions Bot/assistant_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,75 @@
import requests
import json
import random
from dotenv import load_dotenv

# instance of the client
Intents = discord.Intents.default()
# Intents.message_content = True
Intents.message_content = True
client = discord.Client(intents=Intents)

# const
sad_words = ["sad", "depressed", "unhappy", "angry", "miserable", "depressing"]

starter_encouragements = [
"Cheer up!",
"Cheer up!",
"You can do it!",
"Hang in there!",
"You are a star!",
"You are a great person!"
]
zen_url = "https://zenquotes.io/api/random"


def get_quote():
"""
This function gets a random quote from the API
This function gets a random quote from the API(zenquotes)
API references is below.
(https://zenquotes.io/)
return value is {'q': ~~~, 'a': ~~~, 'h': ~~~}
"""
url = "https://zenquotes.io/api/random"
response = requests.get(url)
headers = {'user-agent': 'vscode-restclient'}
response = requests.request("GET", zen_url, headers=headers)
json_data = json.loads(response.text)
quote = json_data[0]['q'] + " - " + json_data[0]['a']
return quote
if not json_data[0]:
return "failed fetching data... Anyway, you can do it!!!"
return json_data[0]


@client.event
async def on_ready(): # when the bot is ready to use
async def on_ready(): # when the bot is ready to use
print(f'We have logged in as {client.user}')
# "Hey there! I'm your personal assistant. I can help you with anything you need. Just ask me!"

@client.event # this tells the library we are listening to a message event
async def on_message(message): # when the bot recieves a message
if message.author == client.user: # if the message is from the bot (ourselves)
return # we don't want to reply to ourselves

if message.content.startswith('!hello'): # if the message starts with !hello
await message.channel.send(f'Hello humans!') # reply with Hello!
@client.event # this tells the library we are listening to a message event
async def on_message(message): # when the bot recieves a message
# if the message is from the bot (ourselves)
if message.author == client.user:
return # we don't want to reply to ourselves

# if the message starts with !hello
if message.content.startswith('!hello'):
await message.channel.send(f'Hello humans!') # reply with Hello!
# await message.author.send('Hello there!') # send a message to the author

if message.content.startswith('!inspire'): # if the message starts with !inspire
author_name = message.author.name.split()[0] # get the author's name
quote = get_quote()

# if the message starts with !inspire
if message.content.startswith('!inspire'):
author_name = message.author.name.split()[0] # get the author's name
json_data = get_quote()
quote = json_data['q']
# await message.channel.send(quote)
await message.reply(author_name + ", " + quote)


# if the message contains negative words("sad", "depressed", "unhappy", "angry", "miserable", "depressing")
# return a sentence that can motivate the user
if any(word in message.content for word in sad_words):
json_data = get_quote()
quote = json_data['q']
author = json_data['a']

await message.channel.send(quote + '- by ' + author)
await message.channel.send(random.choice(starter_encouragements))
# message.channel.send("I'm sorry to hear that. I'm always here to help!")

Token = os.getenv('AUTH_TOKEN')
client.run(Token) # run the bot with the token
load_dotenv()
Token = os.getenv('AUTH_TOKEN')
client.run(Token) # run the bot with the token
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Code Network Discord Bot version 2.0 member developed.
@Steve-Hun
@Kriswill72
@draykophoenix
@Takao-Mizuno

##Feature Requests
*add your name next to features you are working on!*
Expand All @@ -17,7 +18,7 @@ Code Network Discord Bot version 2.0 member developed.
- When2Meet meeting scheduling assistant - using a service or custom algorithm create a scheduling assistant that can provide best meeting time suggestions based on those who will be required for the meeting
- Custom notification cards (like how MEE6 command cards are) for notification messages. These can be used to schedule meetings and or standups from each team.
- Lofi and music integration
- Witty conversation AI response if anyone of the team members in the general chat sound sad - it should try and provide motivation
- Witty conversation AI response if anyone of the team members in the general chat sound sad - it should try and provide motivation (TakaoMizuno)
- meme of the day post in the meme's channel
- RSS Feed integration / News integration to keep everyone upto date on tech news
- Implement daily 'code challenges' into Discord bot to improve member engagment