more refinements for the deployment
All checks were successful
Build container / Build (pull_request) Successful in 1m10s

This commit is contained in:
2025-07-29 15:58:34 +02:00
parent 29d951427d
commit f7478fb1e3
15 changed files with 180 additions and 99 deletions

View File

@@ -1,5 +1,5 @@
from pathlib import Path
from peewee import *
db = DatabaseProxy()
class BaseModel(Model):
@@ -13,7 +13,7 @@ class ListModel(BaseModel):
@property
def content(self) -> dict:
return {e.id: e.entry for e in self.entries}
@content.setter
def content(self, new_content: dict):
old_content = self.content
@@ -29,7 +29,7 @@ class ListModel(BaseModel):
@property
def done_dict(self):
return {e.id: e.done for e in self.entries}
@done_dict.setter
def done_dict(self, new_done: dict):
old_done_dict = self.done_dict
@@ -46,7 +46,8 @@ class ListEntryModel(BaseModel):
done = BooleanField(default=None, null=True)
def set_db(db_path):
def set_db(db_path: Path):
db_path.parent.mkdir(parents=True, exist_ok=True)
db.initialize(SqliteDatabase(db_path))
with db:
db.create_tables([ListModel, ListEntryModel], safe=True)

View File

@@ -7,10 +7,14 @@ from telegram.constants import ParseMode
import os
FIRST = 1
import models
from .basehandler import BaseHandler
class StatusHandler(BaseHandler):
"""Shows a short status of the program."""
def __init__(self, entry_string):
self.start_time = datetime.datetime.now()
self.entry_string = entry_string
@@ -35,7 +39,6 @@ class StatusHandler(BaseHandler):
reply_markup = InlineKeyboardMarkup(keyboard)
delta = str(datetime.datetime.now() - self.start_time)
message = "BeebBop, this is Norbit\n"
try:
ip = httpx.get('https://api.ipify.org').text
@@ -47,18 +50,21 @@ class StatusHandler(BaseHandler):
ip = "not fetchable"
local_ips = "not fetchable"
message += "Status: Running 🟢\n"
message += f"Version: `{os.getenv('BOT_VERSION', 'dev')}`\n"
message += f"Uptime: `{delta[:delta.rfind('.')]}`\n"
message += f"IP \(public\): `{ip}`\n"
message += f"IP \(private\): `{local_ips}`\n"
message += f"Chat ID: `{update.effective_chat.id}`\n"
message = f"""
BeebBop\!
Status: Running 🟢
Version: `{os.getenv('BOT_VERSION', 'dev')}` and`prod={models.IS_PRODUCTION}`
Uptime: `{delta[:delta.rfind('.')]}`
IP \(public\): `{ip}`
IP \(private\): `{local_ips}`
Chat ID: `{update.effective_chat.id}`
""".strip() # remove trailing whitespace
if update.message:
await update.message.reply_text(message, reply_markup=reply_markup, parse_mode=ParseMode.MARKDOWN_V2)
else:
await update._effective_chat.send_message(message, reply_markup=reply_markup, parse_mode=ParseMode.MARKDOWN_V2)
return FIRST