template message
This commit is contained in:
parent
c13eb0e6df
commit
6c0f9e34c1
11
main.py
11
main.py
@ -4,6 +4,9 @@ import yaml
|
|||||||
import requests
|
import requests
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
|
# To send discord messages (fucking async functions…)
|
||||||
|
import asyncio
|
||||||
|
|
||||||
from apscheduler.schedulers.background import BackgroundScheduler
|
from apscheduler.schedulers.background import BackgroundScheduler
|
||||||
scheduler = BackgroundScheduler()
|
scheduler = BackgroundScheduler()
|
||||||
scheduler.start()
|
scheduler.start()
|
||||||
@ -67,12 +70,13 @@ def cleaner ():
|
|||||||
# TODO erase calc revenus ?
|
# TODO erase calc revenus ?
|
||||||
|
|
||||||
@scheduler.scheduled_job('cron', day=5)
|
@scheduler.scheduled_job('cron', day=5)
|
||||||
async def reminder ():
|
def reminder ():
|
||||||
for i in guilds:
|
for i in guilds:
|
||||||
|
print(f"reminding {i} : {guilds[i]['mailing']}")
|
||||||
message = generate_reminder_message(guilds[i])
|
message = generate_reminder_message(guilds[i])
|
||||||
send_mail(guilds[i], 'La mutunion c’est bientôt !', message)
|
send_mail(guilds[i], 'La mutunion c’est bientôt !', message)
|
||||||
channel = client.get_channel(guilds[i]['reminder_channel'])
|
channel = client.get_channel(guilds[i]['reminder_channel'])
|
||||||
await channel.send(message)
|
asyncio.run_coroutine_threadsafe(channel.send(message), client.loop)
|
||||||
|
|
||||||
|
|
||||||
def generate_reminder_message (guild):
|
def generate_reminder_message (guild):
|
||||||
@ -87,7 +91,7 @@ Coucou !
|
|||||||
Il est l’heure de déclarer ses revenus :
|
Il est l’heure de déclarer ses revenus :
|
||||||
<{guild['link_declaration']}>
|
<{guild['link_declaration']}>
|
||||||
|
|
||||||
Et d’annoncer à quelle heure vous souhaitez faire la mututu :
|
Et d’annoncer à quelle heure vous souhaitez faire la mutunion :
|
||||||
<{sondage}>
|
<{sondage}>
|
||||||
|
|
||||||
Bon début de mois :D
|
Bon début de mois :D
|
||||||
@ -107,7 +111,6 @@ async def on_ready():
|
|||||||
print(f'{client.user} is connected to the following guild:\n')
|
print(f'{client.user} is connected to the following guild:\n')
|
||||||
for guild in client.guilds:
|
for guild in client.guilds:
|
||||||
print(f'{guild.name} (id: {guild.id})')
|
print(f'{guild.name} (id: {guild.id})')
|
||||||
await reminder()
|
|
||||||
|
|
||||||
@client.event
|
@client.event
|
||||||
async def on_message(message):
|
async def on_message(message):
|
||||||
|
Loading…
Reference in New Issue
Block a user