|
|
|
@ -63,6 +63,7 @@ class Plugin:
|
|
|
|
|
|
|
|
|
|
def __init__(self, bot):
|
|
|
|
|
from edmond.bot import Bot
|
|
|
|
|
|
|
|
|
|
self.bot: Bot = bot
|
|
|
|
|
# self.name is the plugin name, lowercased, without the Plugin suffix.
|
|
|
|
|
self.name: str = self.__class__.__name__.lower()[:-6]
|
|
|
|
@ -139,6 +140,7 @@ class Plugin:
|
|
|
|
|
self.bot.storage[name] = {key: value}
|
|
|
|
|
else:
|
|
|
|
|
self.bot.storage[name][key] = value
|
|
|
|
|
self.bot.save_storage()
|
|
|
|
|
|
|
|
|
|
def append_storage_list_value(self, key: str, value: Any) -> None:
|
|
|
|
|
"""Append a value to a list in the plugin persistent storage."""
|
|
|
|
@ -148,6 +150,7 @@ class Plugin:
|
|
|
|
|
self.bot.storage[self.name][key] = [value]
|
|
|
|
|
else:
|
|
|
|
|
self.bot.storage[self.name][key].append(value)
|
|
|
|
|
self.bot.save_storage()
|
|
|
|
|
|
|
|
|
|
def remove_storage_list_value(self, key: str, value: Any) -> None:
|
|
|
|
|
"""Remove a value from a persistent storage list."""
|
|
|
|
@ -156,6 +159,7 @@ class Plugin:
|
|
|
|
|
and key in self.bot.storage[self.name]
|
|
|
|
|
):
|
|
|
|
|
self.bot.storage[self.name][key].remove(value)
|
|
|
|
|
self.bot.save_storage()
|
|
|
|
|
|
|
|
|
|
def should_read_message(self, message: str) -> Optional[str]:
|
|
|
|
|
"""Return a message content if it has been addressed to me, else None.
|
|
|
|
@ -308,7 +312,9 @@ class Plugin:
|
|
|
|
|
self.command = command
|
|
|
|
|
self.bot.log_i(f"Processing command from p. {self.name}: {command}")
|
|
|
|
|
|
|
|
|
|
def respects_handling_conditions(self, exclude_conditions: Optional[dict] = None):
|
|
|
|
|
def respects_handling_conditions(
|
|
|
|
|
self, exclude_conditions: Optional[dict] = None
|
|
|
|
|
):
|
|
|
|
|
"""Check if handling conditions are valid.
|
|
|
|
|
|
|
|
|
|
Handling conditions can be specified by each plugin to create states in
|
|
|
|
|