ability to disable tracking altogether, small comment changes
This commit is contained in:
@@ -10,6 +10,8 @@ warn_threshold_days: 30
|
|||||||
# number of days of inactivity to be considered in the "danger zone"
|
# number of days of inactivity to be considered in the "danger zone"
|
||||||
kick_threshold_days: 60
|
kick_threshold_days: 60
|
||||||
|
|
||||||
|
# track users? if false, will disable all tracking and avoid writing anything to the database.
|
||||||
|
track_users: True
|
||||||
|
|
||||||
# track messages? if false, will not track user activity timestamps. enable if you'd like to track
|
# track messages? if false, will not track user activity timestamps. enable if you'd like to track
|
||||||
# inactive users in your community
|
# inactive users in your community
|
||||||
@@ -39,6 +41,7 @@ invitees:
|
|||||||
# you can use {user} to reference the joining user in this message using a
|
# you can use {user} to reference the joining user in this message using a
|
||||||
# matrix.to link (rendered as a "pill" in element clients)
|
# matrix.to link (rendered as a "pill" in element clients)
|
||||||
# html formatting is supported
|
# html formatting is supported
|
||||||
|
# set to {} if you don't care about greetings
|
||||||
greetings:
|
greetings:
|
||||||
generic: |
|
generic: |
|
||||||
Welcome {user}! Please be sure to read the topic for helpful links and information.
|
Welcome {user}! Please be sure to read the topic for helpful links and information.
|
||||||
@@ -50,6 +53,7 @@ greetings:
|
|||||||
# which of the above greetings should be used in which rooms? use the exact name of each greeting
|
# which of the above greetings should be used in which rooms? use the exact name of each greeting
|
||||||
# you've assigned, e.g. 'generic' or 'encrypted'. you must use the room ID here.
|
# you've assigned, e.g. 'generic' or 'encrypted'. you must use the room ID here.
|
||||||
# enter 'none' to avoid sending a message, but still be notified in the notification_room listed below.
|
# enter 'none' to avoid sending a message, but still be notified in the notification_room listed below.
|
||||||
|
# set to {} if you don't care about greetings or join notifications
|
||||||
greeting_rooms:
|
greeting_rooms:
|
||||||
'!someroomid:server.tld': generic
|
'!someroomid:server.tld': generic
|
||||||
'!someotherroom:server.tld': generic
|
'!someotherroom:server.tld': generic
|
||||||
|
|||||||
+34
-13
@@ -24,6 +24,7 @@ class Config(BaseProxyConfig):
|
|||||||
helper.copy("admins")
|
helper.copy("admins")
|
||||||
helper.copy("moderators")
|
helper.copy("moderators")
|
||||||
helper.copy("parent_room")
|
helper.copy("parent_room")
|
||||||
|
helper.copy("track_users")
|
||||||
helper.copy("track_messages")
|
helper.copy("track_messages")
|
||||||
helper.copy("track_reactions")
|
helper.copy("track_reactions")
|
||||||
helper.copy("warn_threshold_days")
|
helper.copy("warn_threshold_days")
|
||||||
@@ -48,6 +49,9 @@ class CommunityBot(Plugin):
|
|||||||
|
|
||||||
|
|
||||||
async def do_sync(self) -> None:
|
async def do_sync(self) -> None:
|
||||||
|
if not self.config["track_users"]:
|
||||||
|
return "user tracking is disabled"
|
||||||
|
|
||||||
space_members_obj = await self.client.get_joined_members(self.config["parent_room"])
|
space_members_obj = await self.client.get_joined_members(self.config["parent_room"])
|
||||||
space_members_list = space_members_obj.keys()
|
space_members_list = space_members_obj.keys()
|
||||||
table_users = await self.database.fetch("SELECT mxid FROM user_events")
|
table_users = await self.database.fetch("SELECT mxid FROM user_events")
|
||||||
@@ -181,7 +185,7 @@ class CommunityBot(Plugin):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log.error(f"Flagged message could not be redacted: {e}")
|
self.log.error(f"Flagged message could not be redacted: {e}")
|
||||||
|
|
||||||
if not self.config["track_messages"]:
|
if not self.config["track_messages"] or not self.config["track_users"]:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
q = """
|
q = """
|
||||||
@@ -194,7 +198,7 @@ class CommunityBot(Plugin):
|
|||||||
|
|
||||||
@event.on(EventType.REACTION)
|
@event.on(EventType.REACTION)
|
||||||
async def update_reaction_timestamp(self, evt: MessageEvent) -> None:
|
async def update_reaction_timestamp(self, evt: MessageEvent) -> None:
|
||||||
if not self.config["track_reactions"]:
|
if not self.config["track_reactions"] or not self.config["track_users"]:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
q = """
|
q = """
|
||||||
@@ -205,7 +209,7 @@ class CommunityBot(Plugin):
|
|||||||
"""
|
"""
|
||||||
await self.database.execute(q, evt.sender, evt.timestamp)
|
await self.database.execute(q, evt.sender, evt.timestamp)
|
||||||
|
|
||||||
@command.new("community", help="track active/inactive status of members of a space")
|
@command.new("community", help="manage rooms and members of a space")
|
||||||
async def community(self) -> None:
|
async def community(self) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -214,6 +218,10 @@ class CommunityBot(Plugin):
|
|||||||
in case they are missing")
|
in case they are missing")
|
||||||
async def sync_space_members(self, evt: MessageEvent) -> None:
|
async def sync_space_members(self, evt: MessageEvent) -> None:
|
||||||
if evt.sender in self.config["admins"]:
|
if evt.sender in self.config["admins"]:
|
||||||
|
if not self.config["track_users"]:
|
||||||
|
await evt.respond("user tracking is disabled")
|
||||||
|
return
|
||||||
|
|
||||||
results = await self.do_sync()
|
results = await self.do_sync()
|
||||||
|
|
||||||
added_str = "<br />".join(results['added'])
|
added_str = "<br />".join(results['added'])
|
||||||
@@ -227,6 +235,10 @@ class CommunityBot(Plugin):
|
|||||||
@command.argument("mxid", "full matrix ID", required=True)
|
@command.argument("mxid", "full matrix ID", required=True)
|
||||||
async def ignore_inactivity(self, evt: MessageEvent, mxid: UserID) -> None:
|
async def ignore_inactivity(self, evt: MessageEvent, mxid: UserID) -> None:
|
||||||
if evt.sender in self.config["admins"]:
|
if evt.sender in self.config["admins"]:
|
||||||
|
if not self.config["track_users"]:
|
||||||
|
await evt.reply("user tracking is disabled")
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
Client.parse_user_id(mxid)
|
Client.parse_user_id(mxid)
|
||||||
await self.database.execute("UPDATE user_events SET ignore_inactivity = 1 WHERE \
|
await self.database.execute("UPDATE user_events SET ignore_inactivity = 1 WHERE \
|
||||||
@@ -242,6 +254,10 @@ class CommunityBot(Plugin):
|
|||||||
@command.argument("mxid", "full matrix ID", required=True)
|
@command.argument("mxid", "full matrix ID", required=True)
|
||||||
async def unignore_inactivity(self, evt: MessageEvent, mxid: UserID) -> None:
|
async def unignore_inactivity(self, evt: MessageEvent, mxid: UserID) -> None:
|
||||||
if evt.sender in self.config["admins"]:
|
if evt.sender in self.config["admins"]:
|
||||||
|
if not self.config["track_users"]:
|
||||||
|
await evt.reply("user tracking is disabled")
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
Client.parse_user_id(mxid)
|
Client.parse_user_id(mxid)
|
||||||
await self.database.execute("UPDATE user_events SET ignore_inactivity = 0 WHERE \
|
await self.database.execute("UPDATE user_events SET ignore_inactivity = 0 WHERE \
|
||||||
@@ -255,16 +271,21 @@ class CommunityBot(Plugin):
|
|||||||
|
|
||||||
@community.subcommand("report", help='generate a list of matrix IDs that have been inactive')
|
@community.subcommand("report", help='generate a list of matrix IDs that have been inactive')
|
||||||
async def get_report(self, evt: MessageEvent) -> None:
|
async def get_report(self, evt: MessageEvent) -> None:
|
||||||
sync_results = await self.do_sync()
|
if evt.sender in self.config["admins"]:
|
||||||
report = await self.generate_report()
|
if not self.config["track_users"]:
|
||||||
await evt.respond(f"<b>Users inactive for between {self.config['warn_threshold_days']} and \
|
await evt.reply("user tracking is disabled")
|
||||||
{self.config['kick_threshold_days']} days:</b><br /> \
|
return
|
||||||
{'<br />'.join(report['warn_inactive'])} <br />\
|
|
||||||
<b>Users inactive for at least {self.config['kick_threshold_days']} days:</b><br /> \
|
sync_results = await self.do_sync()
|
||||||
{'<br />'.join(report['kick_inactive'])} <br /> \
|
report = await self.generate_report()
|
||||||
<b>Ignored users:</b><br /> \
|
await evt.respond(f"<b>Users inactive for between {self.config['warn_threshold_days']} and \
|
||||||
{'<br />'.join(report['ignored'])}", \
|
{self.config['kick_threshold_days']} days:</b><br /> \
|
||||||
allow_html=True)
|
{'<br />'.join(report['warn_inactive'])} <br />\
|
||||||
|
<b>Users inactive for at least {self.config['kick_threshold_days']} days:</b><br /> \
|
||||||
|
{'<br />'.join(report['kick_inactive'])} <br /> \
|
||||||
|
<b>Ignored users:</b><br /> \
|
||||||
|
{'<br />'.join(report['ignored'])}", \
|
||||||
|
allow_html=True)
|
||||||
|
|
||||||
|
|
||||||
@community.subcommand("purge", help='kick users for excessive inactivity')
|
@community.subcommand("purge", help='kick users for excessive inactivity')
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
maubot: 0.1.0
|
maubot: 0.1.0
|
||||||
id: org.jobmachine.communitybot
|
id: org.jobmachine.communitybot
|
||||||
version: 0.1.7
|
version: 0.1.8
|
||||||
license: MIT
|
license: MIT
|
||||||
modules:
|
modules:
|
||||||
- community
|
- community
|
||||||
|
|||||||
Reference in New Issue
Block a user