-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
63 lines (48 loc) · 1.6 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import discord
import os
import requests
import json
import random
from replit import db
client = discord.Client()
sad_words = [
"sad", "frustrated", "anxious", "tired", "mad", "depressed", "down",
"angry", "depressing", "exhausting", "low"
]
starter_encouragements = [
'Hi there, you are absoluty amazing. Hang in there',
'Hey, you are brillant. You will get through this',
'You are amazing my dear friend. Do not be sad', 'You are loved',
'Cheer up', 'Hang in there'
]
def get_qoute():
response = requests.get('https://zenquotes.io/api/random/')
json_data = json.loads(response.text)
qoute = json_data[0]['q'] + " -" + json_data[0]['a']
return qoute
def update_encouragements(encouraging_message):
if "encouragements" in db.keys():
encouragements = db["encouragements"]
encouragements.append(encouraging_message)
db["encouragements"] = encouragements
else:
db["encouragements"] = [encouraging_message]
def delete_encouragements(index):
encouragements = db["encouragements"]
if len (encouragements) > index:
del encouragements[index]
db["encouragements"] = encouragements
@client.event
async def on_ready():
print('We are logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
msg = message.content
if msg.startswith('$inspire'):
qoute = get_qoute()
await message.channel.send(qoute)
if any(word in msg for word in sad_words):
await message.channel.send(random.choice(starter_encouragements))
client.run(os.getenv('TOKEN'))