def _handle(self, data): cam_id, update = self._bot._updates.pop(data['event_id']) name = data['name'] switch = data['params']['switch'] msg = data.get('msg') or '{0} stream successfully {1}'.format( name, 'enabled' if switch else 'disabled') update.message.reply_html(make_bold(msg)) self._log.info(msg)
def _send_resized_photo(self, data): cam_id, update = self._bot._updates.pop(data['event_id']) meta = self._cam_registry.get_conf(cam_id) caption = f'Snapshot taken on {format_ts(data["create_ts"])} ' \ f'(snapshot #{data["taken_count"]})' caption = f'{caption}\n/cmds_{cam_id}, /list' reply_html = f'Sending snapshot from {meta.description}' self._log.info('Sending resized cam snapshot') self._bot.reply_cam_photo(photo=data.get('img'), update=update, caption=caption, reply_html=make_bold(reply_html)) self._log.info('Resized snapshot sent')
def _send_full_photo(self, data): cam_id, update = self._bot._updates.pop(data['event_id']) meta = self._cam_registry.get_conf(cam_id) _date = format_ts(data["create_ts"]) filename = f'Full snapshot {_date}.jpg' caption = f'Full snapshot at {_date} ' \ f'(snapshot #{data["taken_count"]})' caption = f'{caption}\n/cmds_{cam_id}, /list' reply_html = f'Sending snapshot from {meta.description}' self._log.info('Sending resized cam snapshot') self._bot.reply_cam_photo(photo=data.get('img'), update=update, caption=caption, reply_html=make_bold(reply_html), fullpic_name=filename, fullpic=True) self._log.info('Full snapshot %s sent', filename)
def cmd_list_cams(update, ctx): """List user's cameras.""" log.info('Camera list has been requested') cam_count = ctx.bot.cam_registry.get_count() msg = [ make_bold('You have {0} camera{1}'.format( cam_count, '' if cam_count == 1 else 's')) ] for cam_id, meta in ctx.bot.cam_registry.get_all().items(): presentation = build_commands_presentation(ctx.bot, cam_id) msg.append('<b>Camera:</b> {0}\n' '<b>Description:</b> {1}\n' '<b>Commands</b>\n' '{2}'.format(cam_id, meta['conf'].description, presentation)) update.message.reply_html('\n\n'.join(msg)) log.info('Camera list has been sent')