示例#1
0
    async def _handle(self, event: DetectionConfOutboundEvent) -> None:
        message = event.message
        name: str = DETECTION_SWITCH_MAP[event.type]['name'].value
        switch = event.switch

        text: str = event.text or '{0} successfully {1}'.format(
            name, 'enabled' if switch else 'disabled')
        await send_text(text=bold(text), message=message, quote=True)
示例#2
0
 async def _handle(self, event: IrcutConfEvent) -> None:
     await event.cam.set_ircut_filter(filter_type=event.filter_type)
     await self._result_queue.put(
         SendTextOutboundEvent(
             event=Event.SEND_TEXT,
             message=event.message,
             text=bold('OK'),
         )
     )
示例#3
0
 async def _handle(self, event: StreamOutboundEvent) -> None:
     message = event.message
     stream_type = event.stream_type
     switch = event.switch
     text: str = event.text or '{0} stream successfully {1}'.format(
         stream_type.value.capitalize(),
         'enabled' if switch else 'disabled')
     await send_text(text=bold(text), message=message, quote=True)
     self._log.info(text)
示例#4
0
 async def _send_confirmation_message(self) -> None:
     if self._video_type is VideoGifType.ON_DEMAND:
         text = f'Recording video gif for {self._rec_time} seconds'
         await self._result_queue.put(
             SendTextOutboundEvent(
                 event=Event.SEND_TEXT,
                 message=self._message,
                 text=bold(text),
             ))
示例#5
0
async def cmd_list_groups(bot: CameraBot, message: Message) -> None:
    group_registry = bot.cam_registry.get_groups_registry()
    count = len(group_registry)
    plural = '' if count == 1 else 's'
    msg = [bold(f'You have {count} camera group{plural}\n')]

    for command, meta in bot.cam_registry.get_groups_registry().items():
        msg.append(f'/{command} - {meta["name"]}')

    msg.append('\n/help')
    await send_text(text='\n'.join(msg), message=message, quote=True)
示例#6
0
async def cmd_list_cams(bot: CameraBot, message: Message) -> None:
    """List user's cameras."""
    log.debug('Camera list has been requested')
    count = bot.cam_registry.count()
    plural = '' if count == 1 else 's'
    msg = [bold(f'You have {count} camera{plural}')]

    for cam_id, meta in bot.cam_registry.get_all().items():
        msg.append(f'<b>Camera:</b> {cam_id}\n'
                   f'<b>Description:</b> {meta["cam"].description}\n'
                   f'<b>Commands</b>: /cmds_{cam_id}')
    msg.append('/groups, /help')
    await send_text(text='\n\n'.join(msg), message=message, quote=True)
    log.debug('Camera list has been sent')
示例#7
0
async def cmd_list_group_cams(bot: CameraBot, message: Message) -> None:
    meta = bot.cam_registry.get_group(message.command[0])
    cam_count = len(meta['cams'])
    plural = '' if cam_count == 1 else 's'
    msg = [
        bold(f'You have {cam_count} camera{plural} in group "{meta["name"]}"')
    ]

    cam: HikvisionCam
    for cam in meta['cams']:
        msg.append(f'<b>Camera:</b> {cam.id}\n'
                   f'<b>Description:</b> {cam.description}\n'
                   f'<b>Commands</b>: /cmds_{cam.id}')
    msg.append('/groups, /help')
    await send_text(text='\n\n'.join(msg), message=message, quote=True)