diff --git a/config_sample/config.yaml b/config_sample/config.yaml index bf103f12..9aea1c3e 100644 --- a/config_sample/config.yaml +++ b/config_sample/config.yaml @@ -151,6 +151,11 @@ unban_webhook: username: Unban avatar_url: +login_webhook: + enabled: true + username: Login + avatar_url: + need_webhook: enabled: true delay: 60 diff --git a/server/commands/admin.py b/server/commands/admin.py index 364b4bb7..e9b12148 100644 --- a/server/commands/admin.py +++ b/server/commands/admin.py @@ -322,6 +322,7 @@ def ooc_cmd_login(client, arg): client.area.broadcast_evidence_list() client.send_ooc("Logged in as a moderator.") + client.server.webhooks.login(client, login_name) database.log_misc("login", client, data={"profile": login_name}) diff --git a/server/network/webhooks.py b/server/network/webhooks.py index f2d2d8df..76506992 100644 --- a/server/network/webhooks.py +++ b/server/network/webhooks.py @@ -91,6 +91,21 @@ def modcall(self, char, ipid, area, reason=None): description=description, ) + def login(self, client=None, loginprofile=""): + if "login_webhook" not in self.server.config: + return + is_enabled = self.server.config["login_webhook"]["enabled"] + username = self.server.config["login_webhook"]["username"] + avatar_url = self.server.config["login_webhook"]["avatar_url"] + + if not is_enabled: + return + + message = f"{client.name} ({client.ipid}) (hdid: {client.hdid}) has logged in as mod profile: {loginprofile}" + + self.send_webhook(username=username, + avatar_url=avatar_url, message=message) + def needcall(self, client=None, reason=None): if "need_webhook" not in self.server.config: return