-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
69 lines (51 loc) · 2.01 KB
/
bot.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
64
65
66
67
68
69
import discord
import requests
import json
import random
client = discord.Client()
def get_quote():
response = requests.get("https://zenquotes.io/api/random")
json_data = json.loads(response.text)
quote = json_data[0]['q'] + "-" + json_data[0]['a']
return(quote)
def get_joke():
response = requests.get("https://v2.jokeapi.dev/joke/Programming,Miscellaneous,Dark,Pun,Spooky,Christmas?blacklistFlags=religious&type=twopart")
json_data = json.loads(response.text)
setup = json_data["setup"]
punchline = json_data["delivery"]
return (setup,punchline)
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_ready1():
await client.change_presence(activity = discord.Activity(type=discord.ActivityType.Listening, name='w.[location]'))
@client.event
async def on_message(message):
username = str(message.author).split('#')[0]
user_message = str(message.content)
channel = str(message.channel.name)
print(f'{username}:{user_message} ({channel})')
if message.author == client.user:
return
if message.content.startswith('&hello'):
await message.channel.send('Hey!')
if message.content.startswith('&inspire'):
quote=get_quote()
await message.channel.send(quote)
if message.content.startswith('&joke'):
joke = get_joke()
await message.channel.send(joke)
if message.content== '&alone':
await message.author.send('HELLO, HEARD YOU ARE ALONE SO LETS HAVE FUN TOGETHER!')
if message.content.startswith('hi'):
await message.channel.send(f'Hello,{username}!')
return
if user_message.lower()=='bye':
await message.channel.send(f'See you later, {username}!')
return
if user_message.lower()=='!random':
response = f'This is your random number:{random.randrange(1000000)}'
await message.channel.send(response)
return
client.run('MTA1NTIwNTU0MDc5NzYyODQ4Ng.GiqJ3H.gbvob-N-ZlanKmRy3wzpO1i4OzLUDeJjpFRpLM')