remove invite and react callbacks
This commit is contained in:
@@ -78,73 +78,75 @@ class Callbacks:
|
||||
await command.process()
|
||||
|
||||
async def invite(self, room: MatrixRoom, event: InviteMemberEvent) -> None:
|
||||
"""Callback for when an invite is received. Join the room specified in the invite.
|
||||
#"""Callback for when an invite is received. Join the room specified in the invite.
|
||||
|
||||
Args:
|
||||
room: The room that we are invited to.
|
||||
#Args:
|
||||
# room: The room that we are invited to.
|
||||
|
||||
event: The invite event.
|
||||
"""
|
||||
logger.debug(f"Got invite to {room.room_id} from {event.sender}.")
|
||||
# event: The invite event.
|
||||
#"""
|
||||
#logger.debug(f"Got invite to {room.room_id} from {event.sender}.")
|
||||
|
||||
# Attempt to join 3 times before giving up
|
||||
for attempt in range(3):
|
||||
result = await self.client.join(room.room_id)
|
||||
if type(result) == JoinError:
|
||||
logger.error(
|
||||
f"Error joining room {room.room_id} (attempt %d): %s",
|
||||
attempt,
|
||||
result.message,
|
||||
)
|
||||
else:
|
||||
break
|
||||
else:
|
||||
logger.error("Unable to join room: %s", room.room_id)
|
||||
## Attempt to join 3 times before giving up
|
||||
#for attempt in range(3):
|
||||
# result = await self.client.join(room.room_id)
|
||||
# if type(result) == JoinError:
|
||||
# logger.error(
|
||||
# f"Error joining room {room.room_id} (attempt %d): %s",
|
||||
# attempt,
|
||||
# result.message,
|
||||
# )
|
||||
# else:
|
||||
# break
|
||||
#else:
|
||||
# logger.error("Unable to join room: %s", room.room_id)
|
||||
|
||||
# Successfully joined room
|
||||
logger.info(f"Joined {room.room_id}")
|
||||
## Successfully joined room
|
||||
#logger.info(f"Joined {room.room_id}")
|
||||
return
|
||||
|
||||
async def _reaction(
|
||||
self, room: MatrixRoom, event: UnknownEvent, reacted_to_id: str
|
||||
) -> None:
|
||||
"""A reaction was sent to one of our messages. Let's send a reply acknowledging it.
|
||||
#"""A reaction was sent to one of our messages. Let's send a reply acknowledging it.
|
||||
|
||||
Args:
|
||||
room: The room the reaction was sent in.
|
||||
#Args:
|
||||
# room: The room the reaction was sent in.
|
||||
|
||||
event: The reaction event.
|
||||
# event: The reaction event.
|
||||
|
||||
reacted_to_id: The event ID that the reaction points to.
|
||||
"""
|
||||
logger.debug(f"Got reaction to {room.room_id} from {event.sender}.")
|
||||
# reacted_to_id: The event ID that the reaction points to.
|
||||
#"""
|
||||
#logger.debug(f"Got reaction to {room.room_id} from {event.sender}.")
|
||||
|
||||
# Get the original event that was reacted to
|
||||
event_response = await self.client.room_get_event(room.room_id, reacted_to_id)
|
||||
if isinstance(event_response, RoomGetEventError):
|
||||
logger.warning(
|
||||
"Error getting event that was reacted to (%s)", reacted_to_id
|
||||
)
|
||||
return
|
||||
reacted_to_event = event_response.event
|
||||
## Get the original event that was reacted to
|
||||
#event_response = await self.client.room_get_event(room.room_id, reacted_to_id)
|
||||
#if isinstance(event_response, RoomGetEventError):
|
||||
# logger.warning(
|
||||
# "Error getting event that was reacted to (%s)", reacted_to_id
|
||||
# )
|
||||
# return
|
||||
#reacted_to_event = event_response.event
|
||||
|
||||
# Only acknowledge reactions to events that we sent
|
||||
if reacted_to_event.sender != self.config.user_id:
|
||||
return
|
||||
## Only acknowledge reactions to events that we sent
|
||||
#if reacted_to_event.sender != self.config.user_id:
|
||||
# return
|
||||
|
||||
# Send a message acknowledging the reaction
|
||||
reaction_sender_pill = make_pill(event.sender)
|
||||
reaction_content = (
|
||||
event.source.get("content", {}).get("m.relates_to", {}).get("key")
|
||||
)
|
||||
message = (
|
||||
f"{reaction_sender_pill} reacted to this event with `{reaction_content}`!"
|
||||
)
|
||||
await send_text_to_room(
|
||||
self.client,
|
||||
room.room_id,
|
||||
message,
|
||||
reply_to_event_id=reacted_to_id,
|
||||
)
|
||||
## Send a message acknowledging the reaction
|
||||
#reaction_sender_pill = make_pill(event.sender)
|
||||
#reaction_content = (
|
||||
# event.source.get("content", {}).get("m.relates_to", {}).get("key")
|
||||
#)
|
||||
#message = (
|
||||
# f"{reaction_sender_pill} reacted to this event with `{reaction_content}`!"
|
||||
#)
|
||||
#await send_text_to_room(
|
||||
# self.client,
|
||||
# room.room_id,
|
||||
# message,
|
||||
# reply_to_event_id=reacted_to_id,
|
||||
#)
|
||||
return
|
||||
|
||||
async def decryption_failure(self, room: MatrixRoom, event: MegolmEvent) -> None:
|
||||
"""Callback for when an event fails to decrypt. Inform the user.
|
||||
|
||||
Reference in New Issue
Block a user