This repository has been archived by the owner on Sep 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.py
112 lines (86 loc) · 3.76 KB
/
core.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
import discord
from discord.ext import commands
from discord.ext.commands import Bot
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from core import gestion as ge, utils, level as lvl
from gems import gemsFonctions as GF
import gg_lib as gg
from datetime import date
# initialisation des variables.
DEFAUT_PREFIX = "!"
VERSION = open("core/version.txt").read().replace("\n", "")
TOKEN = open("token/token.txt", "r").read().replace("\n", "")
PREFIX = open("core/prefix.txt", "r").read().replace("\n", "")
client = commands.Bot(command_prefix="{0}".format(PREFIX))
NONE = open("help/cogs.txt", "w")
NONE = open("help/help.txt", "w")
client.remove_command("help")
# Au démarrage du Bot.
@client.event
async def on_ready():
global GGconnect
print('Connecté avec le nom : {0.user}'.format(client))
print('PREFIX = '+str(PREFIX))
print('\nGet Gems - Client Discord '+VERSION)
GF.setglobalguild(client.get_guild(utils.ServIDmoji))
print('------\n')
GGconnect, utils.nb_saisons, utils.date_saison = ge.ZMQ()
print('------\n')
activity = discord.Activity(type=discord.ActivityType.playing, name="{0}help | Season {1}".format(PREFIX, utils.nb_saisons))
await client.change_presence(status=discord.Status.online, activity=activity)
scheduler = AsyncIOScheduler()
tab_date_saison = utils.date_saison.split("-")
scheduler.add_job(request_date_end_season, 'date', run_date=date(int(tab_date_saison[2]), int(tab_date_saison[1]), int(tab_date_saison[0])), id="REQUEST_SEASON")
scheduler.start()
scheduler.print_jobs()
async def request_date_end_season():
ge.socket.send_string(gg.std_send_command('req_date', '__client', 'discord'))
socks = dict(ge.poll.poll(ge.REQUEST_TIMEOUT))
if socks.get(ge.socket) == ge.zmq.POLLIN:
msg = ge.socket.recv()
msg_DEC = msg.decode()
utils.nb_saisons = utils.nb_saisons + 1
utils.date_saison = msg_DEC
D = msg_DEC.split("-")
scheduler = AsyncIOScheduler()
scheduler.reschedule_job('REQUEST_SEASON', trigger='date', run_date=date(int(D[2]), int(D[1]), int(D[0])))
scheduler.start()
scheduler.print_jobs()
activity = discord.Activity(type=discord.ActivityType.playing, name="{0}help | Season {1}".format(PREFIX, utils.nb_saisons))
await client.change_presence(status=discord.Status.online, activity=activity)
####################### Commande help.py #######################
client.load_extension('help.help')
################### Core ############################
client.load_extension('core.utils')
####################### Welcome ####################################
@client.event
async def on_guild_join(guild):
if guild.system_channel != None:
systemchannel = guild.system_channel
else:
systemchannel = 0
param = dict()
param["IDGuild"] = guild.id
param["name"] = guild.name
ge.socket.send_string(gg.std_send_command("NewServer", guild.id, ge.name_pl, param))
GF.msg_recv()
await systemchannel.send('Bonjour **{0}**!'.format(guild.name))
####################### Stat ####################################
@client.event
async def on_message(message):
if not (message.author.bot) and message.content.startswith(PREFIX):
if GGconnect:
await lvl.checklevel(message)
await client.process_commands(message)
####################### Commande gems.py #######################
client.load_extension('gems.gemsBase')
client.load_extension('gems.gemsPlay')
client.load_extension('gems.gemsSuccess')
# client.load_extension('gems.gemsGuild')
# client.load_extension('gems.gemsEvent')
client.load_extension('gems.gemsAdmin')
####################### Lancemement du bot ######################
try:
client.run(TOKEN)
except (KeyboardInterrupt, SystemExit):
pass