Added Spoutnik
This commit is contained in:
49
run.py
49
run.py
@@ -5,13 +5,14 @@ import asyncio
|
||||
import random
|
||||
import base64
|
||||
import emoji
|
||||
import codenames
|
||||
import wordle
|
||||
import ephemeris
|
||||
import polls
|
||||
import spoutnik
|
||||
from datetime import datetime
|
||||
import cambot.codenames as codenames
|
||||
import cambot.wordle as wordle
|
||||
import cambot.ephemeris as ephemeris
|
||||
import cambot.polls as polls
|
||||
from cambot.emojis import *
|
||||
from cambot.settings import *
|
||||
from emojis import *
|
||||
from settings import *
|
||||
|
||||
intents = nextcord.Intents.default()
|
||||
intents.typing = False
|
||||
@@ -21,6 +22,7 @@ intents.message_content = True
|
||||
bot = nextcord.Client(intents=intents)
|
||||
codenames_games = {}
|
||||
wordle_games = {}
|
||||
spoutnik_games = {}
|
||||
|
||||
# Startup
|
||||
@bot.event
|
||||
@@ -36,6 +38,11 @@ async def on_ready():
|
||||
wordle_game = wordle.Game(channel)
|
||||
wordle_games[channel_id] = wordle_game
|
||||
print(f"Écoute pour Wordle sur {channel.guild} > {channel.name}")
|
||||
for channel_id in SPOUTNIK_CHANNEL_IDS:
|
||||
channel = bot.get_channel(channel_id)
|
||||
spoutnik_game = spoutnik.Game(channel)
|
||||
spoutnik_games[channel_id] = spoutnik_game
|
||||
print(f"Écoute pour Spoutnik sur {channel.guild} > {channel.name}")
|
||||
|
||||
current_date = None
|
||||
while True:
|
||||
@@ -54,6 +61,10 @@ async def on_ready():
|
||||
elif event[0] == WORDLE:
|
||||
for wordle_game in wordle_games.values():
|
||||
await wordle_game.reset()
|
||||
elif event[0] == SPOUTNIK:
|
||||
for spoutnik_game in spoutnik_games.values():
|
||||
await spoutnik_game.reset()
|
||||
|
||||
|
||||
# Receiving a message
|
||||
@bot.event
|
||||
@@ -77,7 +88,7 @@ async def on_message(message):
|
||||
to_say = regex.group(2)
|
||||
await bot.get_channel(channel_id).send(to_say)
|
||||
|
||||
if regex := re.search(r"^[wW]ordle targets?$", content_lowercase):
|
||||
if re.search(r"^[wW]ordle targets?$", content_lowercase):
|
||||
output = ""
|
||||
for wordle_game in wordle_games.values():
|
||||
output += f"{wordle_game.channel.guild} > {wordle_game.channel.name} : {wordle_game.target}\n"
|
||||
@@ -87,7 +98,17 @@ async def on_message(message):
|
||||
channel_id = int(regex.group(1))
|
||||
await wordle_games[channel_id].reset()
|
||||
|
||||
if regex := re.search(r"^[eE]phemeris$", content_lowercase):
|
||||
if re.search(r"^[sS]poutnik targets?$", content_lowercase):
|
||||
output = ""
|
||||
for spoutnik_game in spoutnik_games.values():
|
||||
output += f"{spoutnik_game.channel.guild} > {spoutnik_game.channel.name} : {spoutnik_game.target}\n"
|
||||
await message.author.send(output)
|
||||
|
||||
if regex := re.search(r"^[sS]poutnik reset ([0-9]+)$", content_lowercase):
|
||||
channel_id = int(regex.group(1))
|
||||
await spoutnik_games[channel_id].reset()
|
||||
|
||||
if re.search(r"^[eE]phemeris$", content_lowercase):
|
||||
embed = ephemeris.digest()
|
||||
for channel_id in EPHEMERIS_CHANNEL_IDS:
|
||||
await bot.get_channel(channel_id).send(embed=embed)
|
||||
@@ -207,6 +228,10 @@ async def on_message(message):
|
||||
if message.channel.id in wordle_games.keys():
|
||||
await wordle_games[message.channel.id].parse(message)
|
||||
|
||||
# Spoutnik
|
||||
if message.channel.id in spoutnik_games.keys():
|
||||
await spoutnik_games[message.channel.id].parse(message)
|
||||
|
||||
# Polls
|
||||
bullet = r"(\b[a-zA-Z]\))"
|
||||
if re.search(bullet, content):
|
||||
@@ -266,12 +291,12 @@ async def print_help(channel):
|
||||
|
||||
# Let unprivileged users pin messages
|
||||
async def reaction_changed(payload):
|
||||
emoji = payload.emoji
|
||||
if not emoji.is_unicode_emoji():
|
||||
em = payload.emoji
|
||||
if not em.is_unicode_emoji():
|
||||
return
|
||||
if(len(emoji.name) != 1): # flags, Fitzpatrick skin tone, variation selectors...
|
||||
if len(em.name) != 1: # flags, Fitzpatrick skin tone, variation selectors...
|
||||
return
|
||||
if emoji.name != PUSHPIN:
|
||||
if em.name != PUSHPIN:
|
||||
return
|
||||
event_type = payload.event_type
|
||||
message = await bot.get_channel(payload.channel_id).fetch_message(payload.message_id)
|
||||
|
||||
Reference in New Issue
Block a user