-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCSW_Discord_bot.py
More file actions
83 lines (77 loc) · 3.31 KB
/
CSW_Discord_bot.py
File metadata and controls
83 lines (77 loc) · 3.31 KB
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
82
83
import discord
import time
def gotest(list1):
j = ""
for i in range(len(list1)):
j = j + list1[i]
return j
client = discord.Client()
token="your_token"
@client.event
async def on_ready():
print(client.user.id)
print("ready")
game = discord.Game("Hello World")
await client.change_presence(status=discord.Status.online, activity=game)
@client.event
async def on_message(message):
check = 1
week = ["월요일","화요일","수요일","목요일","금요일","토요일","일요일"]
if message.content.startswith("!hello"):
f = open('discord data/hello.txt','r')
h = f.readlines()
now = time.localtime()
n = time.localtime().tm_wday
await message.channel.send(gotest(h)+"\n"
+"```"
+"```"+"cs"+"\n"
+"'Today is "+("%04d/%02d/%02d" % (now.tm_year, now.tm_mon, now.tm_mday))+ " " +week[n] + "'"+"\n"
+"'This time is "+("%02d:%02d:%02d" % (now.tm_hour, now.tm_min, now.tm_sec))
+"'```")
if message.content.startswith("!help"):
f = open('discord data/help.txt','r')
h = f.readlines()
await message.channel.send(gotest(h))
if message.content.startswith("!time"):
now = time.localtime()
await message.channel.send("```cs"+"\n"+"'"+("%02d:%02d:%02d" % (now.tm_hour, now.tm_min, now.tm_sec))+"'```")
if message.content.startswith("!day"):
now = time.localtime()
n = time.localtime().tm_wday
await message.channel.send("```cs"+"\n"+"'"+(("%04d/%02d/%02d" % (now.tm_year, now.tm_mon, now.tm_mday))+ " " +week[n])+"'```")
if message.content.startswith("!now"):
now = time.localtime()
n = time.localtime().tm_wday
await message.channel.send("```cs"+"\n"+"'"+(("%04d/%02d/%02d" % (now.tm_year, now.tm_mon, now.tm_mday))+ " " +week[n])+"'"+"\n"
+"'"+("%02d:%02d:%02d" % (now.tm_hour, now.tm_min, now.tm_sec))
+"'```")
if message.content.startswith("!python"):
f = open('discord data/python.txt','r')
h = f.readlines()
await message.channel.send(gotest(h))
if message.content.startswith("!java"):
f = open('discord data/java.txt','r')
h = f.readlines()
await message.channel.send(gotest(h))
if message.content.startswith("!html"):
f = open('discord data/html.txt','r')
h = f.readlines()
await message.channel.send(gotest(h))
if message.content.startswith("!c++"):
f = open('discord data/c++.txt','r')
h = f.readlines()
await message.channel.send(gotest(h))
elif message.content.startswith("!c#"):
f = open('discord data/c#.txt','r')
h = f.readlines()
await message.channel.send(gotest(h))
elif message.content.startswith("!c"):
f = open('discord data/c.txt','r')
h = f.readlines()
await message.channel.send(gotest(h))
if message.content.startswith("!go"):
f = open('discord data/go.txt','r')
h = f.readlines()
await message.channel.send(gotest(h))
client.run(token)
f.close()