def test_manual_deactivate(self): RemoteControlManager.activate(UID, CID_SRC, CID_DEST) RemoteControlManager.deactivate(UID, CID_SRC) self.assertIsNone( RemoteControlManager.get_current(UID, CID_SRC, update_expiry=False), "Entry still inside the holder.")
def remote_control_status(e: TextMessageEventObject): current = RemoteControlManager.get_current(e.user_model.id, e.channel_model_source.id, update_expiry=False) if current: cnl = current.target_channel if not cnl: RemoteControlManager.deactivate(e.user_model.id, e.channel_model_source.id) return [ HandledMessageEventText(content=_( "Target channel data not found. Terminating remote control.\n" "Target Channel ID: `{}`").format( current.target_channel_oid)) ] else: return [ HandledMessageEventText( content=_("Remote control is activated.\n" "Target Channel ID: `{}`\n" "Target Channel Platform & Name: *{} / {}*\n" "Will be deactivated at `{}`.").format( cnl.id, cnl.platform.key, cnl.get_channel_name(e.user_model.id), current.expiry_str)) ] else: return [ HandledMessageEventText( content=_("Remote control is not activated.")) ]
def remote_control_activate(e: TextMessageEventObject, target_channel: ObjectId): entry = RemoteControlManager.activate( e.user_model.id, e.channel_model_source.id, target_channel, e.user_model.config.get_locale_code()) if entry.target_channel: return [ HandledMessageEventText(content=_("Remote control activated.")) ] else: RemoteControlManager.deactivate(e.user_model.id, e.channel_model_source.id) return [ HandledMessageEventText(content=_( "Target channel not found. Failed to activate remote control.") ) ]
def remote_control_deactivate(e: TextMessageEventObject): if RemoteControlManager.deactivate(e.user_model.id, e.channel_model_source.id): return [ HandledMessageEventText(content=_("Remote control deactivated.")) ] else: if RemoteControlManager.get_current(e.user_model.id, e.channel_model_source.id, update_expiry=False): return [ HandledMessageEventText( content=_("Remote control failed to delete.")) ] else: return [ HandledMessageEventText( content=_("Remote control not activated.")) ]