summaryrefslogtreecommitdiff
path: root/src/sound_bot.py
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2022-06-28 03:22:30 +0300
committerEvgeny Zinoviev <me@ch1p.io>2022-06-30 03:47:49 +0300
commit8f20c9b825cabab7a3f0f5dd2cfe000cc7f72c28 (patch)
treeb5d7446e7b2fcfd42b1e5029aeef33ecb5f9715f /src/sound_bot.py
parentee09bc98aedfc6a65a5026432b399345a30a39c8 (diff)
polaris pwk 1725cgld full support
- significant improvements, correctnesses and stability fixes in protocol implementation - correct handling of device appearances and disappearances - flawlessly functioning telegram bot that re-renders kettle's state (temperature and other) in real time
Diffstat (limited to 'src/sound_bot.py')
-rwxr-xr-xsrc/sound_bot.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/sound_bot.py b/src/sound_bot.py
index b515ae7..91e51f0 100755
--- a/src/sound_bot.py
+++ b/src/sound_bot.py
@@ -6,7 +6,7 @@ import tempfile
from enum import Enum
from datetime import datetime, timedelta
from html import escape
-from typing import Optional
+from typing import Optional, List, Dict, Tuple
from home.config import config
from home.bot import Wrapper, Context, text_filter, user_any_name
@@ -27,11 +27,11 @@ from telegram.ext import (
from PIL import Image
logger = logging.getLogger(__name__)
-RenderedContent = tuple[str, Optional[InlineKeyboardMarkup]]
+RenderedContent = Tuple[str, Optional[InlineKeyboardMarkup]]
record_client: Optional[SoundRecordClient] = None
bot: Optional[Wrapper] = None
-node_client_links: dict[str, SoundNodeClient] = {}
-cam_client_links: dict[str, CameraNodeClient] = {}
+node_client_links: Dict[str, SoundNodeClient] = {}
+cam_client_links: Dict[str, CameraNodeClient] = {}
def node_client(node: str) -> SoundNodeClient:
@@ -73,7 +73,7 @@ def interval_defined(interval: int) -> bool:
return interval in config['bot']['record_intervals']
-def callback_unpack(ctx: Context) -> list[str]:
+def callback_unpack(ctx: Context) -> List[str]:
return ctx.callback_query.data[3:].split('/')
@@ -115,7 +115,7 @@ class SettingsRenderer(Renderer):
@classmethod
def node(cls, ctx: Context,
- controls: list[dict]) -> RenderedContent:
+ controls: List[dict]) -> RenderedContent:
node, = callback_unpack(ctx)
html = []
@@ -169,7 +169,7 @@ class RecordRenderer(Renderer):
return html, cls.places_markup(ctx, callback_prefix='r0')
@classmethod
- def node(cls, ctx: Context, durations: list[int]) -> RenderedContent:
+ def node(cls, ctx: Context, durations: List[int]) -> RenderedContent:
node, = callback_unpack(ctx)
html = ctx.lang('select_interval')
@@ -241,7 +241,7 @@ class FilesRenderer(Renderer):
return html, cls.places_markup(ctx, callback_prefix='f0')
@classmethod
- def filelist(cls, ctx: Context, files: list[SoundRecordFile]) -> RenderedContent:
+ def filelist(cls, ctx: Context, files: List[SoundRecordFile]) -> RenderedContent:
node, = callback_unpack(ctx)
html_files = map(lambda file: cls.file(ctx, file, node), files)
@@ -936,7 +936,6 @@ class SoundBot(Wrapper):
# cheese
self.add_handler(CallbackQueryHandler(self.wrap(camera_capture), pattern=r'^c1/.*'))
-
def markup(self, ctx: Optional[Context]) -> Optional[ReplyKeyboardMarkup]:
buttons = [
[ctx.lang('record'), ctx.lang('settings')],