add timezone config option and use said timezone in social credit

This commit is contained in:
leander committed 2026-10-24 04:10:18 +02:00
1 parent 6ac9ed0884
commit b8522b95eb
3 files changed
+7 -2

No files matched your search

+2 -2
View File
@@ -316,7 +316,7 @@ class SocialCredit(commands.Cog):
illegal_hours = [5, 6, 7, 8, 9]
if message.created_at.hour in illegal_hours:
if message.created_at.astimezone(self.bot.timezone).hour in illegal_hours:
await self.social_punishment(message.author.id, 10, "early-bird")
@roll(percent=50)
@@ -331,7 +331,7 @@ class SocialCredit(commands.Cog):
happy_hours = [1, 2, 3, 4]
if message.created_at.hour in happy_hours:
if message.created_at.astimezone(self.bot.timezone).hour in happy_hours:
await self.social_reward(message.author.id, 10, "night-owl")
async def robort_slur(self, message: discord.Message):
+3
View File
@@ -2,6 +2,9 @@ config_mode: dev
dev_guild: 747542543750660178
# IANA timezone name. Leave empty to use the system's timezone
timezone: Europe/Oslo
# Bot settings
bot:
token:
+2
View File
@@ -2,6 +2,7 @@ import asyncio
import signal
from os import listdir
from time import time
from zoneinfo import ZoneInfo
import discord
import psycopg2
@@ -72,6 +73,7 @@ class Bot(commands.Bot):
self.presence = config["bot"].get("presence", {})
self.emoji = config.get("emoji", {})
self.misc = config.get("misc", {})
self.timezone = ZoneInfo(tz) if (tz := config.get("timezone")) else None # None means the system timezone
async def setup_hook(self):
# Docker stops the container with SIGTERM. Close gracefully so cogs can save their caches