-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.py
81 lines (65 loc) · 3.26 KB
/
run.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
70
71
72
73
74
75
76
77
78
79
80
81
import os
from dotenv import load_dotenv,find_dotenv
import random
from urllib import request,parse
import json
import discord
load_dotenv(find_dotenv())
client = discord.Client()
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
@client.event
async def on_message(message):
print(message.content)
if message.content.startswith("/aup/"):
# 送り主がBotだった場合反応したくないので
if client.user != message.author:
slice = message.content[5:]
url = 'http://aikatsup.com/api/v1/search?' + parse.urlencode({"words": slice})
# => 'http://www.lifewithpython.com/abc/python.html'
req = request.Request(url)
with request.urlopen(req) as res:
body = res.read()
data = json.loads(body)
if ('item' in data):
total = len(data['item'])
post_no = random.randint(0, total - 1)
await client.send_message(message.channel, data['item'][post_no]['image']['url'])
else:
await client.send_message(message.channel, '見つからないよー><')
if message.content.startswith("<:okokokay:"):
# 送り主がBotだった場合反応したくないので
if client.user != message.author:
m = "https://drive.google.com/uc?authuser=0&id=1zwQ2pkqlgMk4nQGEdLKX6LG8p5n8cfWH&export=download"
await client.send_message(message.channel, m)
if message.content.startswith("<:dx_kowai:"):
# 送り主がBotだった場合反応したくないので
if client.user != message.author:
m = "https://drive.google.com/uc?authuser=0&id=1dTd6iInoBTNeljiseanCBeephKkiRQJ3&export=download"
await client.send_message(message.channel, m)
if message.content.startswith("<:aikatsu_tbcss:"):
# 送り主がBotだった場合反応したくないので
if client.user != message.author:
m = "https://drive.google.com/uc?authuser=0&id=1wky3TXWVrD3SzNOU6u4aUlLtoeX-fzA7&export=download"
await client.send_message(message.channel, m)
if message.content.startswith("<:aikatsu_not_odayaka:"):
# 送り主がBotだった場合反応したくないので
if client.user != message.author:
m = "https://drive.google.com/uc?authuser=0&id=1i3yRK5pYG5KW7o2IA9kWTOHUNOi4SxxQ&export=download"
await client.send_message(message.channel, m)
if message.content.startswith("<:aikatsu_aasouiukotoka:"):
# 送り主がBotだった場合反応したくないので
if client.user != message.author:
m = "https://drive.google.com/uc?authuser=0&id=1PZJYW2voXxKvRMhQWyEChJpno6IXQ5op&export=download"
await client.send_message(message.channel, m)
if message.content.startswith("<:noja_yaranakereba:"):
# 送り主がBotだった場合反応したくないので
if client.user != message.author:
m = "https://drive.google.com/uc?authuser=0&id=1ANCTItSnqAzKCP8cxfZEAaB-0xxNzGjb&export=download"
await client.send_message(message.channel, m)
API_KEY= os.environ.get("API_KEY")
client.run(API_KEY)