added ability to customize actibity further, and changed settings to example

This commit is contained in:
ctih1 2025-07-26 00:10:31 +03:00
parent b67aebd9b1
commit 068829702e
4 changed files with 62 additions and 15 deletions

1
.gitignore vendored
View file

@ -14,3 +14,4 @@ translationcompleteness.py
modules/volta
log.txt
settings/admin_logs.json
settings/settings.json

24
bot.py
View file

@ -31,7 +31,7 @@ from modules import key_compiler
import logging
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
from modules.settings import instance as settings_manager
from modules.settings import instance as settings_manager, ActivityType
from modules.permission import requires_admin
import threading
@ -183,12 +183,28 @@ async def on_ready() -> None:
traceback.print_exc()
quit()
if not settings["bot"]["misc"]["active_song"]:
if not settings["bot"]["misc"]["activity"]["content"]:
return
activity_type = discord.ActivityType.unknown
settings_activity = settings["bot"]["misc"]["activity"]["type"]
activities: Dict[ActivityType, discord.ActivityType] = {
"listening": discord.ActivityType.listening,
"playing": discord.ActivityType.playing,
"streaming": discord.ActivityType.streaming,
"competing": discord.ActivityType.competing,
"watching": discord.ActivityType.watching,
}
await bot.change_presence(
activity=discord.Activity(
type=discord.ActivityType.listening,
name=settings["bot"]["misc"]["active_song"],
type=activities.get(
settings["bot"]["misc"]["activity"]["type"],
discord.ActivityType.unknown,
),
name=settings["bot"]["misc"]["activity"]["content"],
)
)
launched = True

View file

@ -7,10 +7,17 @@ import copy
logger = logging.getLogger("goober")
ActivityType = Literal["listening", "playing", "streaming", "competing", "watching"]
class Activity(TypedDict):
content: str
type: ActivityType
class MiscBotOptions(TypedDict):
ping_line: str
active_song: str
activity: Activity
positive_gifs: List[str]
block_profanity: bool
@ -66,6 +73,25 @@ class Settings:
self.log_path: str = os.path.join(".", "settings", "admin_logs.json")
self.migrate()
def migrate(self):
active_song: str | None = (
self.settings.get("bot", {}).get("misc", {}).get("active_song")
)
if active_song:
logger.warning("Found deprecated active_song, migrating")
self.settings["bot"]["misc"]["activity"] = {
"content": active_song,
"type": "listening",
}
del self.settings["bot"]["misc"]["active_song"] # type: ignore
self.commit()
def reload_settings(self) -> None:
with open(self.path, "r") as f:
self.__kv_store: dict = json.load(f)

View file

@ -1,29 +1,33 @@
{
"bot": {
"prefix": "ä.",
"prefix": "p.",
"owner_ids": [
642441889181728810,
642441889181728810
],
"blacklisted_users": [
1391805740716527666
],
"blacklisted_users": [],
"user_training": true,
"allow_show_mem_command": true,
"react_to_messages": true,
"misc": {
"ping_line": "The Beretta fires fast and won't make you feel any better!",
"active_song": "Basket Case - Green Day",
"positive_gifs": [],
"block_profanity": false
"positive_gifs": [
"https://tenor.com/view/i-want-a-divorce-dissolution-annulment-seperation-break-up-gif-25753155"
],
"block_profanity": false,
"activity": {
"content": "Rakas - Haloo Helsinki",
"type": "listening"
}
},
"active_memory": "memory.json",
"enabled_cogs": [
"fuckup",
"songchanger",
"pulse",
"breaking_news"
]
},
"locale": "fi",
"locale": "en",
"name": "gubert",
"auto_update": true,
"disable_checks": false,