forked from gooberinc/goober
added ability to customize actibity further, and changed settings to example
This commit is contained in:
parent
b67aebd9b1
commit
068829702e
4 changed files with 62 additions and 15 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -13,4 +13,5 @@ translation_report.txt
|
||||||
translationcompleteness.py
|
translationcompleteness.py
|
||||||
modules/volta
|
modules/volta
|
||||||
log.txt
|
log.txt
|
||||||
settings/admin_logs.json
|
settings/admin_logs.json
|
||||||
|
settings/settings.json
|
24
bot.py
24
bot.py
|
@ -31,7 +31,7 @@ from modules import key_compiler
|
||||||
import logging
|
import logging
|
||||||
from watchdog.observers import Observer
|
from watchdog.observers import Observer
|
||||||
from watchdog.events import FileSystemEventHandler
|
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
|
from modules.permission import requires_admin
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
|
@ -183,12 +183,28 @@ async def on_ready() -> None:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
quit()
|
quit()
|
||||||
|
|
||||||
if not settings["bot"]["misc"]["active_song"]:
|
if not settings["bot"]["misc"]["activity"]["content"]:
|
||||||
return
|
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(
|
await bot.change_presence(
|
||||||
activity=discord.Activity(
|
activity=discord.Activity(
|
||||||
type=discord.ActivityType.listening,
|
type=activities.get(
|
||||||
name=settings["bot"]["misc"]["active_song"],
|
settings["bot"]["misc"]["activity"]["type"],
|
||||||
|
discord.ActivityType.unknown,
|
||||||
|
),
|
||||||
|
name=settings["bot"]["misc"]["activity"]["content"],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
launched = True
|
launched = True
|
||||||
|
|
|
@ -7,10 +7,17 @@ import copy
|
||||||
|
|
||||||
logger = logging.getLogger("goober")
|
logger = logging.getLogger("goober")
|
||||||
|
|
||||||
|
ActivityType = Literal["listening", "playing", "streaming", "competing", "watching"]
|
||||||
|
|
||||||
|
|
||||||
|
class Activity(TypedDict):
|
||||||
|
content: str
|
||||||
|
type: ActivityType
|
||||||
|
|
||||||
|
|
||||||
class MiscBotOptions(TypedDict):
|
class MiscBotOptions(TypedDict):
|
||||||
ping_line: str
|
ping_line: str
|
||||||
active_song: str
|
activity: Activity
|
||||||
positive_gifs: List[str]
|
positive_gifs: List[str]
|
||||||
block_profanity: bool
|
block_profanity: bool
|
||||||
|
|
||||||
|
@ -66,6 +73,25 @@ class Settings:
|
||||||
|
|
||||||
self.log_path: str = os.path.join(".", "settings", "admin_logs.json")
|
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:
|
def reload_settings(self) -> None:
|
||||||
with open(self.path, "r") as f:
|
with open(self.path, "r") as f:
|
||||||
self.__kv_store: dict = json.load(f)
|
self.__kv_store: dict = json.load(f)
|
||||||
|
|
|
@ -1,29 +1,33 @@
|
||||||
{
|
{
|
||||||
"bot": {
|
"bot": {
|
||||||
"prefix": "ä.",
|
"prefix": "p.",
|
||||||
"owner_ids": [
|
"owner_ids": [
|
||||||
642441889181728810,
|
642441889181728810
|
||||||
|
],
|
||||||
|
"blacklisted_users": [
|
||||||
1391805740716527666
|
1391805740716527666
|
||||||
],
|
],
|
||||||
"blacklisted_users": [],
|
|
||||||
"user_training": true,
|
"user_training": true,
|
||||||
"allow_show_mem_command": true,
|
"allow_show_mem_command": true,
|
||||||
"react_to_messages": true,
|
"react_to_messages": true,
|
||||||
"misc": {
|
"misc": {
|
||||||
"ping_line": "The Beretta fires fast and won't make you feel any better!",
|
"ping_line": "The Beretta fires fast and won't make you feel any better!",
|
||||||
"active_song": "Basket Case - Green Day",
|
"positive_gifs": [
|
||||||
"positive_gifs": [],
|
"https://tenor.com/view/i-want-a-divorce-dissolution-annulment-seperation-break-up-gif-25753155"
|
||||||
"block_profanity": false
|
],
|
||||||
|
"block_profanity": false,
|
||||||
|
"activity": {
|
||||||
|
"content": "Rakas - Haloo Helsinki",
|
||||||
|
"type": "listening"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"active_memory": "memory.json",
|
"active_memory": "memory.json",
|
||||||
"enabled_cogs": [
|
"enabled_cogs": [
|
||||||
"fuckup",
|
|
||||||
"songchanger",
|
|
||||||
"pulse",
|
"pulse",
|
||||||
"breaking_news"
|
"breaking_news"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locale": "fi",
|
"locale": "en",
|
||||||
"name": "gubert",
|
"name": "gubert",
|
||||||
"auto_update": true,
|
"auto_update": true,
|
||||||
"disable_checks": false,
|
"disable_checks": false,
|
Loading…
Add table
Add a link
Reference in a new issue