diff --git a/GearBot/Cogs/Censor.py b/GearBot/Cogs/Censor.py index 4d2d3073..e31fd0b4 100644 --- a/GearBot/Cogs/Censor.py +++ b/GearBot/Cogs/Censor.py @@ -74,7 +74,7 @@ async def check_message(self, member, content, channel, message_id, edit, reply, censor_emoji_message = await Configuration.get_var(member.guild.id, "CENSORING", "CENSOR_EMOJI_ONLY_MESSAGES") content = content.replace('\\', '') - if Configuration.get_var(member.guild.id, "CENSORING", "IGNORE_IDS"): + if await Configuration.get_var(member.guild.id, "CENSORING", "IGNORE_IDS"): content = re.sub(r'(<(?:@|#|@&|@!)[0-9]{15,20}>)', '', content) content = re.sub(r'', '', content) content = re.sub(r"(https://(?:canary|ptb)?\.?discord(?:app)?.com/channels/\d{15,20}/\d{15,20}/\d{15,20})", '', content) diff --git a/GearBot/GearBot.py b/GearBot/GearBot.py index ff29db89..b87c8d87 100644 --- a/GearBot/GearBot.py +++ b/GearBot/GearBot.py @@ -194,7 +194,17 @@ async def initialize(bot): "shard_ids": [cluster * 2, (cluster * 2) + 1] }) - GearbotLogging.info(f"Ready to go, spinning up as instance {args['cluster'] + 1}/{args['shard_count']}") + elif 'stateful' in os.environ: + GearbotLogging.info(f"GearBot is deployed as stateful set, determining cluster id based on hostname {os.uname()[1]}") + cluster = loop.run_until_complete(node_init(0, 0)) + num_clusters = int(os.environ["num_clusters"]) + args.update({ + "shard_count": num_clusters * 2, + "cluster": cluster, + "shard_ids": [cluster * 2, (cluster * 2) + 1] + }) + + GearbotLogging.info(f"Ready to go, spinning up as instance {args['cluster'] + 1}/{args['shard_count']}") diff --git a/GearBot/Util/MessageUtils.py b/GearBot/Util/MessageUtils.py index a9637964..363d9b31 100644 --- a/GearBot/Util/MessageUtils.py +++ b/GearBot/Util/MessageUtils.py @@ -19,7 +19,7 @@ async def get_message_data(bot, message_id): message = None - if not Object(message_id).created_at <= datetime.datetime.utcfromtimestamp(time.time() - 5 * 60).replace(tzinfo=datetime.timezone.utc): + if not Object(message_id).created_at <= datetime.datetime.utcfromtimestamp(time.time() - 1 * 60).replace(tzinfo=datetime.timezone.utc): parts = await bot.redis_pool.hgetall(f"messages:{message_id}") if len(parts) == 7: reply = int(parts["reply"]) @@ -42,12 +42,12 @@ async def insert_message(bot, message, redis=True): channel=message.channel.id, server=message.guild.id, pinned=1 if message.pinned else 0, attachments='|'.join((f"{str(a.id)}/{str(a.filename)}" for a in message.attachments)), reply=message.reference.message_id if is_reply else 0) if message_type is not None: pipe.hmset_dict(f"messages:{message.id}", type=message_type) - pipe.expire(f"messages:{message.id}", 5*60+2) + pipe.expire(f"messages:{message.id}", 1*60) await pipe.execute() await DBUtils.insert_message(message) async def update_message(bot, message_id, content, pinned): - if not Object(message_id).created_at <= datetime.datetime.utcfromtimestamp(time.time() - 5 * 60).replace(tzinfo=datetime.timezone.utc): + if not Object(message_id).created_at <= datetime.datetime.utcfromtimestamp(time.time() - 1 * 60).replace(tzinfo=datetime.timezone.utc): pipe = bot.redis_pool.pipeline() pipe.hmset_dict(f"messages:{message_id}", content=content) pipe.hmset_dict(f"messages:{message_id}", pinned=(1 if pinned else 0)) diff --git a/requirements.txt b/requirements.txt index 59b55d97..deab6627 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,6 +7,6 @@ sentry-sdk==0.19.2 pytz==2020.4 pyseeyou==1.0.1 prometheus_client==0.8.0 -asyncpg==0.22.0 +asyncpg==0.27.0 emoji==0.6.0 kubernetes==12.0.1 \ No newline at end of file