Compare commits
2 commits
7bfa875f05
...
84de0f7eb5
Author | SHA1 | Date | |
---|---|---|---|
84de0f7eb5 | |||
372a719de0 |
1 changed files with 10 additions and 8 deletions
|
@ -63,8 +63,8 @@ class ApplicationBot:
|
||||||
|
|
||||||
if body and body.startswith("!supportbot"):
|
if body and body.startswith("!supportbot"):
|
||||||
await self.handle_command(room, sender, body)
|
await self.handle_command(room, sender, body)
|
||||||
elif body and body.startswith("!apply"):
|
elif body and body.startswith("!apply") and not sender == self.client.user_id:
|
||||||
await self.process_application(room, sender, body)
|
await self.process_application(room, sender, event)
|
||||||
else:
|
else:
|
||||||
await self.relay_message(room, sender, event)
|
await self.relay_message(room, sender, event)
|
||||||
|
|
||||||
|
@ -108,9 +108,7 @@ class ApplicationBot:
|
||||||
message_body = event.body
|
message_body = event.body
|
||||||
sender = event.sender
|
sender = event.sender
|
||||||
|
|
||||||
logging.info(
|
logging.info(f"Processing reaction {reaction_key} from {sender} in {room.room_id}")
|
||||||
f"Processing reaction {reaction_key} from {sender} in {room.room_id}"
|
|
||||||
)
|
|
||||||
logging.info(f"Message: {message_body}")
|
logging.info(f"Message: {message_body}")
|
||||||
|
|
||||||
if message_body.startswith("Application received from"):
|
if message_body.startswith("Application received from"):
|
||||||
|
@ -203,7 +201,9 @@ class ApplicationBot:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
async def process_application(self, room: MatrixRoom, sender, message_body):
|
async def process_application(self, room: MatrixRoom, sender, event):
|
||||||
|
message_body = event.body
|
||||||
|
|
||||||
# Check if the message is from a ticket room
|
# Check if the message is from a ticket room
|
||||||
ticket_id = await self.get_ticket_id_from_room(room.room_id)
|
ticket_id = await self.get_ticket_id_from_room(room.room_id)
|
||||||
if ticket_id:
|
if ticket_id:
|
||||||
|
@ -221,6 +221,8 @@ class ApplicationBot:
|
||||||
|
|
||||||
# React to the message with approve, reject, and invite emojis
|
# React to the message with approve, reject, and invite emojis
|
||||||
if isinstance(sent_message, RoomMessageText):
|
if isinstance(sent_message, RoomMessageText):
|
||||||
|
logging.debug(f"Reacting to message {sent_message.event_id}")
|
||||||
|
|
||||||
await self.client.room_send(
|
await self.client.room_send(
|
||||||
room.room_id,
|
room.room_id,
|
||||||
"m.reaction",
|
"m.reaction",
|
||||||
|
@ -255,7 +257,7 @@ class ApplicationBot:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
await self.relay_message(room, sender, message_body)
|
await self.relay_message(room, sender, event)
|
||||||
|
|
||||||
async def approve_or_reject_application(self, room, sender, command, approved):
|
async def approve_or_reject_application(self, room, sender, command, approved):
|
||||||
user_id = (
|
user_id = (
|
||||||
|
@ -677,7 +679,7 @@ class ApplicationBot:
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Failed to relay message of type {type(event)}: {e}")
|
logging.error(f"Failed to relay message of type {type(event)}: {e}")
|
||||||
logging.debug(f"Event source: {event.source}")
|
logging.debug(f"Event source: {event}")
|
||||||
|
|
||||||
async def help_command(self, room, sender):
|
async def help_command(self, room, sender):
|
||||||
if await self.is_operator(sender):
|
if await self.is_operator(sender):
|
||||||
|
|
Loading…
Reference in a new issue