Skip to content

Commit

Permalink
Allow discord bot to log when modpass login occurs (#144)
Browse files Browse the repository at this point in the history
* Update admin.py

* Update webhooks.py

* Update webhooks.py

* Update webhooks.py

* Update config.yaml

* Update webhooks.py

* Update webhooks.py

* Update webhooks.py

* Update config.yaml

* Update webhooks.py

* Update config.yaml
  • Loading branch information
axestyra authored Jun 24, 2024
1 parent 88fb2cc commit 9e19886
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
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=""):
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

0 comments on commit 9e19886

Please sign in to comment.