Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clan apply command #80

Merged
merged 6 commits into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions seraphsix/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
InvalidCommandError, InvalidGameModeError, InvalidMemberError,
NotRegisteredError, ConfigurationError, MissingTimezoneError, MaintenanceError)
from seraphsix.tasks.core import create_redis_jobs_pool
from seraphsix.tasks.clan import ack_clan_application
from seraphsix.tasks.discord import store_sherpas, update_sherpa

log = logging.getLogger(__name__)
intents = discord.Intents.default()
intents.members = True
intents.reactions = True

STARTUP_EXTENSIONS = [
'seraphsix.cogs.clan', 'seraphsix.cogs.game', 'seraphsix.cogs.member',
Expand Down Expand Up @@ -148,7 +150,7 @@ async def process_tweet(self, tweet):
async def track_tweets(self):
stream = self.twitter.stream.statuses.filter.post(follow=constants.TWITTER_FOLLOW_USERS)
async for tweet in stream:
if peony.events.tweet(tweet):
if peony.events.tweet(tweet) and not peony.events.retweet(tweet):
if tweet.in_reply_to_status_id:
continue
# For some reason non-followed users sometimes sneak into the stream
Expand All @@ -159,7 +161,7 @@ async def track_tweets(self):
async def connect_redis(self):
self.redis = await aioredis.create_redis_pool(self.config.redis_url)
self.ext_conns['redis_cache'] = self.redis
self.ext_conns['redis_jobs'] = await create_redis_jobs_pool(self.config.arq_redis)
self.ext_conns['redis_jobs'] = await create_redis_jobs_pool()

@tasks.loop(hours=1.0)
async def cache_clan_members(self):
Expand All @@ -183,6 +185,13 @@ async def on_connect(self):
await self.connect_redis()

async def on_ready(self):
guilds = await self.ext_conns['database'].execute(Guild.select())
if not guilds:
return
self.guild_map = {}
for guild in guilds:
self.guild_map[guild.guild_id] = guild

self.log_channel = self.get_channel(self.config.log_channel)
self.reg_channel = self.get_channel(self.config.reg_channel)

Expand All @@ -203,6 +212,11 @@ async def on_member_update(self, before, after):
if not before.bot:
await update_sherpa(self, before, after)

async def on_raw_reaction_add(self, payload):
if payload.channel_id == self.guild_map[payload.guild_id].admin_channel and \
payload.emoji.name in [constants.EMOJI_CHECKMARK, constants.EMOJI_CROSSMARK]:
await ack_clan_application(self, payload)

async def on_guild_join(self, guild):
await self.log_channel.send(f"Seraph Six joined {guild.name} (id:{guild.id})!")

Expand Down
Loading