Release 0.9.0
This commit is contained in:
35
bot/modules/game_environment/triggers/new_bloodmoon.py
Normal file
35
bot/modules/game_environment/triggers/new_bloodmoon.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from bot import loaded_modules_dict
|
||||
from bot import telnet_prefixes
|
||||
from os import path, pardir
|
||||
|
||||
module_name = path.basename(path.normpath(path.join(path.abspath(__file__), pardir, pardir)))
|
||||
trigger_name = path.basename(path.abspath(__file__))[:-3]
|
||||
|
||||
|
||||
def main_function(origin_module, module, regex_result):
|
||||
next_blood_moon = regex_result.group("next_BloodMoon")
|
||||
event_data = ['update_bloodmoon_date', {
|
||||
'blood_moon_date': next_blood_moon,
|
||||
}]
|
||||
module.trigger_action_hook(origin_module, event_data=event_data)
|
||||
|
||||
|
||||
triggers = {
|
||||
"BloodMoon SetDay": r"BloodMoon\sSetDay:\sday\s(?P<next_BloodMoon>\d+)"
|
||||
}
|
||||
|
||||
trigger_meta = {
|
||||
"description": "reacts to updated BloodMoon date in the telnet-stream",
|
||||
"main_function": main_function,
|
||||
"triggers": [
|
||||
{
|
||||
"regex": (
|
||||
telnet_prefixes["telnet_log"]["timestamp"] +
|
||||
triggers["BloodMoon SetDay"]
|
||||
),
|
||||
"callback": main_function
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
loaded_modules_dict["module_" + module_name].register_trigger(trigger_name, trigger_meta)
|
||||
33
bot/modules/game_environment/triggers/shutdown_handler.py
Normal file
33
bot/modules/game_environment/triggers/shutdown_handler.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from bot import loaded_modules_dict
|
||||
from bot import telnet_prefixes
|
||||
from bot.logger import get_logger
|
||||
from os import path, pardir
|
||||
|
||||
module_name = path.basename(path.normpath(path.join(path.abspath(__file__), pardir, pardir)))
|
||||
trigger_name = path.basename(path.abspath(__file__))[:-3]
|
||||
logger = get_logger("game_environment.shutdown_handler")
|
||||
|
||||
|
||||
def main_function(*args, **kwargs):
|
||||
module = args[0]
|
||||
updated_values_dict = kwargs.get("updated_values_dict", {})
|
||||
|
||||
cancel_shutdown = updated_values_dict.get("cancel_shutdown", None)
|
||||
force_shutdown = updated_values_dict.get("force_shutdown", None)
|
||||
|
||||
if cancel_shutdown:
|
||||
logger.info("shutdown_cancelled")
|
||||
if force_shutdown:
|
||||
logger.info("shutdown_forced")
|
||||
|
||||
|
||||
trigger_meta = {
|
||||
"description": "reacts to changes in the shutdown procedure",
|
||||
"main_function": main_function,
|
||||
"handlers": {
|
||||
"module_game_environment/%map_identifier%/cancel_shutdown": main_function,
|
||||
"module_game_environment/%map_identifier%/force_shutdown": main_function
|
||||
}
|
||||
}
|
||||
|
||||
loaded_modules_dict["module_" + module_name].register_trigger(trigger_name, trigger_meta)
|
||||
Reference in New Issue
Block a user