def __init__(self, mxid: UserID, fbid: Optional[int] = None, state: Optional[AndroidState] = None, notice_room: Optional[RoomID] = None) -> None: super().__init__(mxid=mxid, fbid=fbid, state=state, notice_room=notice_room) self.notice_room = notice_room self._notice_room_lock = asyncio.Lock() self._notice_send_lock = asyncio.Lock() self.command_status = None (self.is_whitelisted, self.is_admin, self.permission_level) = self.config.get_permissions(mxid) self._is_logged_in = None self._is_connected = None self._connection_time = time.monotonic() self._prev_thread_sync = -10 self._prev_reconnect_fail_refresh = time.monotonic() self._community_id = None self._sync_lock = SimpleLock("Waiting for thread sync to finish before handling %s", log=self.log) self._is_refreshing = False self._metric_value = defaultdict(lambda: False) self.dm_update_lock = asyncio.Lock() self.log = self.log.getChild(self.mxid) self.client = None self.mqtt = None self.listen_task = None self.seq_id = None
def __init__(self, gid: str, receiver: str, conv_type: int, other_user_id: Optional[str] = None, mxid: Optional[RoomID] = None, encrypted: bool = False, name: str = "", db_instance: Optional[DBPortal] = None) -> None: self.gid = gid self.receiver = receiver if not receiver: raise ValueError("Receiver not given") self.conv_type = conv_type self.other_user_id = other_user_id self.mxid = mxid self.encrypted = encrypted self.name = name self._db_instance = db_instance self._main_intent = None self._create_room_lock = asyncio.Lock() self._last_bridged_mxid = None self._dedup = deque(maxlen=100) self._send_locks = {} self._typing = set() self.log = self.log.getChild(self.gid_log) self.backfill_lock = SimpleLock("Waiting for backfilling to finish before handling %s", log=self.log) self.by_gid[self.full_gid] = self if self.mxid: self.by_mxid[self.mxid] = self
def __init__(self, tgid: TelegramID, peer_type: str, tg_receiver: Optional[TelegramID] = None, mxid: Optional[RoomID] = None, username: Optional[str] = None, megagroup: Optional[bool] = False, title: Optional[str] = None, about: Optional[str] = None, photo_id: Optional[str] = None, local_config: Optional[str] = None, avatar_url: Optional[ContentURI] = None, encrypted: Optional[bool] = False, db_instance: DBPortal = None) -> None: self.mxid = mxid self.tgid = tgid self.tg_receiver = tg_receiver or tgid self.peer_type = peer_type self.username = username self.megagroup = megagroup self.title = title self.about = about self.photo_id = photo_id self.local_config = json.loads(local_config or "{}") self.avatar_url = avatar_url self.encrypted = encrypted self._db_instance = db_instance self._main_intent = None self.deleted = False self.log = self.base_log.getChild(self.tgid_log if self.tgid else self.mxid) self.backfill_lock = SimpleLock("Waiting for backfilling to finish before handling %s", log=self.log) self.backfill_method_lock = asyncio.Lock() self.backfill_leave = None self.dedup = PortalDedup(self) self.send_lock = PortalSendLock() if tgid: self.by_tgid[self.tgid_full] = self if mxid: self.by_mxid[mxid] = self
def __init__(self, mxid: UserID, session: Optional[Dict[str, str]] = None, notice_room: Optional[RoomID] = None, user_agent: Optional[str] = None, fb_domain: str = "messenger.com", db_instance: Optional[DBUser] = None) -> None: self.mxid = mxid self.by_mxid[mxid] = self self.notice_room = notice_room self._notice_room_lock = asyncio.Lock() self._notice_send_lock = asyncio.Lock() self.user_agent = user_agent self.fb_domain = fb_domain self.command_status = None self.is_whitelisted, self.is_admin, self.permission_level = config.get_permissions( mxid) self._is_logged_in = None self._is_connected = None self._connection_time = time.monotonic() self._prev_thread_sync = -10 self._prev_reconnect_fail_refresh = time.monotonic() self._session_data = session self._db_instance = db_instance self._community_id = None self._sync_lock = SimpleLock( "Waiting for thread sync to finish before handling %s", log=self.log) self._is_refreshing = False self._metric_value = defaultdict(lambda: False) self.dm_update_lock = asyncio.Lock() self.log = self.log.getChild(self.mxid) self.client = None self.session = None self.listener = None self.listen_task = None self._handlers = { fbchat.MessageEvent: self.on_message, fbchat.MessageReplyEvent: self.on_message, fbchat.TitleSet: self.on_title_change, fbchat.UnsendEvent: self.on_message_unsent, fbchat.ThreadsRead: self.on_message_seen, fbchat.ReactionEvent: self.on_reaction, fbchat.Presence: self.on_presence, fbchat.Typing: self.on_typing, fbchat.PeopleAdded: self.on_members_added, fbchat.PersonRemoved: self.on_member_removed, fbchat.Connect: self.on_connect, fbchat.Disconnect: self.on_disconnect, fbchat.Resync: self.on_resync, fbchat.UnknownEvent: self.on_unknown_event, }
def __init__(self, twid: str, receiver: int, conv_type: ConversationType, other_user: Optional[int] = None, mxid: Optional[RoomID] = None, name: Optional[str] = None, encrypted: bool = False) -> None: super().__init__(twid, receiver, conv_type, other_user, mxid, name, encrypted) self._create_room_lock = asyncio.Lock() self.log = self.log.getChild(twid) self._msgid_dedup = deque(maxlen=100) self._reaction_dedup = deque(maxlen=100) self._reqid_dedup = set() self._last_participant_update = set() self.backfill_lock = SimpleLock("Waiting for backfilling to finish before handling %s", log=self.log) self._main_intent = None self._reaction_lock = asyncio.Lock()