-
Notifications
You must be signed in to change notification settings - Fork 2
/
bot.py
50 lines (41 loc) · 1.3 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
import discord
import os
import requests
import json
import datetime
VERSION = os.environ['VERSION']
TOKEN = os.environ['DISCORD_TOKEN']
CHANNEL_ID = os.environ['DISCORD_CHANNEL_ID']
client = discord.Client()
@client.event
async def on_ready():
print('Start bot')
@client.event
async def on_message(message):
if message.author.bot:
return
if message.content == "/help":
my_text = get_help_text()
await message.channel.send(my_text)
if message.content == "/version":
await message.channel.send("Bot Version: " + str(VERSION) + "\n" )
if message.content == "/pp":
await message.channel.send(message.channel, file=discord.File("/images/pp.gif","pp.gif"))
if message.content == "/pizza":
await message.channel.send(get_next_pizza_party() )
def get_help_text():
res = "Pastime Bot ver" + str(VERSION) + "\n"
res += "[コマンド一覧]\n"
res += "/help\t\t ヘルプを表示\n"
res += "/pp\t\t\t God Command\n"
return res
def get_next_pizza_party():
now = datetime.datetime.now()
if now.weekday() == 5:
return "Today!"
if now.weekday() == 4:
return "Tomorrow!"
else:
np = now + datetime.timedelta(days=(5-now.weekday())%7)
return np.strftime("%Y/%m/%d (%a) !")
client.run(TOKEN)