2525 BatchSendEvent ,
2626 BatchSendResponse ,
2727 BatchSendStateEvent ,
28+ BeeperBatchSendResponse ,
2829 ContentURI ,
2930 EventContent ,
3031 EventID ,
4041 RoomNameStateEventContent ,
4142 RoomPinnedEventsStateEventContent ,
4243 RoomTopicStateEventContent ,
43- SerializableAttrs ,
4444 StateEventContent ,
4545 UserID ,
4646)
@@ -161,6 +161,8 @@ def user(
161161 user_id: The Matrix ID of the user whose intent API to get.
162162 token: The access token to use for the Matrix ID.
163163 base_url: An optional URL to use for API requests.
164+ as_token: Whether the provided token is actually another as_token
165+ (meaning the ``user_id`` query parameter needs to be used).
164166
165167 Returns:
166168 The IntentAPI for the given user.
@@ -187,7 +189,7 @@ async def set_presence(
187189 Args:
188190 presence: The online status of the user.
189191 status: The status message.
190- ignore_cache: Whether or not to set presence even if the cache says the presence is
192+ ignore_cache: Whether to set presence even if the cache says the presence is
191193 already set to that value.
192194 """
193195 await self .ensure_registered ()
@@ -520,6 +522,9 @@ async def batch_send(
520522
521523 .. versionadded:: v0.12.5
522524
525+ .. deprecated:: v0.20.3
526+ MSC2716 was abandoned by upstream and Beeper has forked the endpoint.
527+
523528 Args:
524529 room_id: The room ID to send the events to.
525530 prev_event_id: The anchor event. The batch will be inserted immediately after this event.
@@ -554,6 +559,52 @@ async def batch_send(
554559 )
555560 return BatchSendResponse .deserialize (resp )
556561
562+ async def beeper_batch_send (
563+ self ,
564+ room_id : RoomID ,
565+ events : Iterable [BatchSendEvent ],
566+ * ,
567+ forward : bool = False ,
568+ forward_if_no_messages : bool = False ,
569+ send_notification : bool = False ,
570+ mark_read_by : UserID | None = None ,
571+ ) -> BeeperBatchSendResponse :
572+ """
573+ Send a batch of events into a room. Only for Beeper/hungryserv.
574+
575+ .. versionadded:: v0.20.3
576+
577+ Args:
578+ room_id: The room ID to send the events to.
579+ events: The events to send.
580+ forward: Send events to the end of the room instead of the beginning
581+ forward_if_no_messages: Send events to the end of the room, but only if there are no
582+ messages in the room. If there are messages, send the new messages to the beginning.
583+ send_notification: Send a push notification for the new messages.
584+ Only applies when sending to the end of the room.
585+ mark_read_by: Send a read receipt from the given user ID atomically.
586+
587+ Returns:
588+ All the event IDs generated.
589+ """
590+ body = {
591+ "events" : [evt .serialize () for evt in events ],
592+ }
593+ if forward :
594+ body ["forward" ] = forward
595+ elif forward_if_no_messages :
596+ body ["forward_if_no_messages" ] = forward_if_no_messages
597+ if send_notification :
598+ body ["send_notification" ] = send_notification
599+ if mark_read_by :
600+ body ["mark_read_by" ] = mark_read_by
601+ resp = await self .api .request (
602+ Method .POST ,
603+ Path .unstable ["com.beeper.backfill" ].rooms [room_id ].batch_send ,
604+ content = body ,
605+ )
606+ return BeeperBatchSendResponse .deserialize (resp )
607+
557608 async def beeper_delete_room (self , room_id : RoomID ) -> None :
558609 versions = await self .versions ()
559610 if not versions .supports ("com.beeper.room_yeeting" ):
0 commit comments