-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorar.py
More file actions
executable file
·52 lines (45 loc) · 1.8 KB
/
orar.py
File metadata and controls
executable file
·52 lines (45 loc) · 1.8 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
import discord
from discord.ext import tasks
import re
import datetime
import json
import asyncio
from event import Events
import configparser
client = discord.Client()
# Discord bot things
@client.event
async def on_ready():
print("The bot is ready!")
client.loop.create_task(updateEvent())
@client.event
async def on_message(message):
try:
if message.content.startswith('.add ') and message.channel.name == "orar_manager":
await message.channel.send(events.add(message.content))
if message.content.startswith('.addR ') and message.channel.name == "orar_manager":
await message.channel.send(events.addR(message.content))
if message.content.startswith('.orar'):
if message.channel.name == "311" or message.channel.name == "312" or message.channel.name == "313" or message.channel.name == "314" or message.channel.name == "315":
await message.channel.send(events.show(message.content, message.channel.name))
else:
await message.channel.send(events.show(message.content, "all"))
if message.content.startswith('.del') and message.channel.name == "orar_manager":
await message.channel.send(events.delete(message.content))
except:
print("We caught an error")
# Move events that passed into the old_events file
async def updateEvent():
while True:
channel = client.get_channel(698667176596471858);
res = events.updateOldEvents()
if res != 0:
await channel.send(res)
await asyncio.sleep(300)
# Inits and config read
config = configparser.ConfigParser()
config.read("./config.ini")
TOKEN = str(config.get("bot", "token"))
events = Events('events.json', 'old_events.json')
# Bot run
client.run(TOKEN)