Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow discord bot to log when modpass login occurs #144

Merged
merged 12 commits into from
Jun 24, 2024
5 changes: 5 additions & 0 deletions config_sample/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ unban_webhook:
username: Unban
avatar_url:

login_webhook:
enabled: true
username: Login
avatar_url:

need_webhook:
enabled: true
delay: 60
Expand Down
1 change: 1 addition & 0 deletions server/commands/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})


Expand Down
15 changes: 15 additions & 0 deletions server/network/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,21 @@ def modcall(self, char, ipid, area, reason=None):
description=description,
)

def login(self, client=None, loginprofile=""):
axestyra marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
Loading