-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
141 lines (113 loc) · 5.36 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import asyncio
import discord
import datetime
from discord.ext import commands
import scheduleParse
from school_guide import *
import pytz
app = commands.Bot(command_prefix='&')
schedule = scheduleParse.schedule()
token = "Ot"
calcResult = 0
class Administrator(commands.Cog, name="관리자"):
def __init__(self, app):
self.app = app
@app.event
async def on_ready():
print("다음으로 로그인합니다 : ")
print(app.user.name)
print(app.user.id)
print("==========")
game = discord.Game("충남중학교") #새로운 코드
await app.change_presence(status=discord.Status.online, activity=game) #바뀜
def setup(app):
app.add_cog(Administrator(app))
@app.command(name = '학사일정')
async def yearSchedule(ctx):
embed = discord.Embed(title='학사일정표', description=" ", color=0x00ff56)
embed.set_author(name="충남중학교", url='https://chungnamms.djsch.kr/scheduleH/list.do?section=1&schdYear=2021')
n = 3
for i in range(12):
embed.add_field(name=str(n if n < 13 else n-12)+'월', value='\n'.join(schedule[n-3]), inline=True)
n+=1
await ctx.send(embed = embed)
@app.command(name = '1학기학사일정')
async def firstTermSchedule(ctx):
embed = discord.Embed(title='1학기 학사일정', description=" ", color=0x00ff56)
embed.set_author(name="충남중학교", url='https://chungnamms.djsch.kr/scheduleH/list.do?section=1&schdYear=2021')
n = 3
for i in range(6):
embed.add_field(name=str(n if n < 13 else n-12)+'월', value='\n'.join(schedule[n-3]), inline=True)
n+=1
await ctx.send(embed = embed)
@app.command(name = '2학기학사일정')
async def secondTermSchedule(ctx):
embed = discord.Embed(title='2학기 학사일정', description=" ", color=0x00ff56)
embed.set_author(name="충남중학교", url='https://chungnamms.djsch.kr/scheduleH/list.do?section=1&schdYear=2021')
n = 9
for i in range(6):
embed.add_field(name=str(n if n < 13 else n-12)+'월', value='\n'.join(schedule[n-3]), inline=True)
n+=1
await ctx.send(embed = embed)
@app.command(name = '이번달학사일정') # fixing
async def monthSchedule(ctx):
month = int(datetime.date.today().isoformat()[5:7])
embed = discord.Embed(title=str(month)+'월 학사일정', description=" ", color=0x00ff56)
embed.set_author(name="충남중학교", url='https://chungnamms.djsch.kr/scheduleH/list.do?section=1&schdYear=2021')
if month < 3:
embed.add_field(name='일정', value='\n'.join(schedule[9+month]), inline=True)
else:
embed.add_field(name='일정', value='\n'.join(schedule[month+2]), inline=True)
await ctx.send(embed = embed)
@app.command(name = '자가진단',pass_context = True)
async def selfCheck(ctx):
embed = discord.Embed(color=0x00ff56)
embed.set_author(name="자가진단 하러가기", url='https://hcs.eduro.go.kr/#/loginHome')
await ctx.send(embed = embed)
@app.command(name = '시간표')
async def sigan(ctx):
embed = discord.Embed(color=0x00ff56)
embed.set_author(name="시간표 보러가기", url='http://xn--s39aj90b0nb2xw6xh.kr/')
await ctx.send(embed = embed)
@app.event
async def on_message(message):
await app.process_commands(message)
if message.author.bot:
return None
msg = message.content #msg == "" or message.content == ""
if msg == "&공지":
embed = discord.Embed(title="**고정된 공지**", description="충남중학교 공지 입니다", timestamp=datetime.datetime.now(pytz.timezone('UTC')), color=0x8cb3ff)
intcon = 0
fixedNotis = school_gtcon()
notis = notifyAll(1)
while intcon <= fixedNotis:
# print(intcon)
embed.add_field(name="{}".format(notis[intcon][0]),value="[바로가기!](<{}>)".format(notis[intcon][1]),inline=True)
intcon = intcon + 1
embed.set_footer(text=message.author, icon_url=message.author.avatar_url)
msg = await message.channel.send(embed=embed)
await msg.add_reaction("▶️")
await msg.add_reaction("❌")
def check(reaction, user):
if user.bot == 1:
return None
return user == message.author and str(reaction.emoji) == '▶️' or user == message.author and str(reaction.emoji) == '❌'
try:
reaction, user = await app.wait_for('reaction_add', timeout=10000.0, check=check)
except asyncio.TimeoutError:
await msg.delete()
else:
if str(reaction.emoji) == "▶️":
await msg.delete()
embed = discord.Embed(title="**공지**", description="충남중학교 공지 입니다", timestamp=datetime.datetime.now(pytz.timezone('UTC')), color=0x8cb3ff)
intcon = fixedNotis
for intcon in range(fixedNotis,len(notis)):
#print(intvalue)
embed.add_field(name="{}".format(notis[intcon][0]),value="[바로가기!](<{}>)".format(notis[intcon][1]),inline=True)
intcon = intcon + 1
#print(intvalue)
embed.set_footer(text=message.author, icon_url=message.author.avatar_url)
await message.channel.send(embed=embed)
if str(reaction.emoji) == "❌":
await msg.delete()
app.run(token)