async def monthly_task(context: ContextTypes.DEFAULT_TYPE):
total_month_expenses = await expense.get_current_month_expenses() # тут строка
await context.bot.send_message(chat_id=context.job.chat_id, text=total_month_expenses)
if __name__ == '__main__':
application = ApplicationBuilder().token(TELEGRAM_TOKEN).build()
start_handler = CommandHandler('start', start) # просто приветсвие
application.add_handler(start_handler)
month_job = application.job_queue
month_job.run_monthly(monthly_task, when=datetime.time(hour=12, minute=50, second=0), day=4)
datetime.time(hour=12, minute=50, second=0)
, то на самом деле это будет 15:50 по МСК. Т. е. для решения этой проблемы, я думаю, нужно или вычитать из времени сколько-то часов (в данном случае 3) или конвертировать местное время в UTC:from datetime import datetime
import pytz
local = pytz.timezone("Europe/Moscow")
naive = datetime.strptime("2024-12-4 12:50:00", "%Y-%m-%d %H:%M:%S")
local_dt = local.localize(naive, is_dst=None)
utc_dt = local_dt.astimezone(pytz.utc)
chat_id (int, optional) –
Chat id of the chat associated with this job. If passed, the corresponding chat_data will be available in the callback.
await context.bot.send_message(chat_id=context.job.chat_id, text=total_month_expenses)
никуда не уйдёт.