mkdryden / telegram-stats-bot

A simple bot that lives in your Telegram group, logging messages to a Postgresql database and serving statistical tables and plots to users as Telegram messages.
GNU General Public License v3.0
53 stars 20 forks source link

2 bugs #27

Closed dinosaurtirex closed 1 year ago

dinosaurtirex commented 1 year ago

Both errors happens on start of tg bot.

First:

2023-11-16 21:36:28,668 - telegram.ext.Application - ERROR - No error handlers are registered, logging exception.
Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\raveon-tg-bot\venv\lib\site-packages\telegram\ext\_application.py", line 1195, in process_update
    await coroutine
  File "C:\Users\Administrator\Desktop\raveon-tg-bot\venv\lib\site-packages\telegram\ext\_basehandler.py", line 153, in handle_update
    return await self.callback(update, context)
  File "C:\Users\Administrator\Desktop\raveon-tg-bot\venv\lib\site-packages\telegram_stats_bot\main.py", line 80, in log_message
    bak_store.append_data('user_events', i)
AttributeError: 'NoneType' object has no attribute 'append_data'

Second:

sqlalchemy.exc.ProgrammingError: (psycopg.errors.SyntaxError) cannot insert multiple commands into a prepared statement
[SQL:
                UPDATE user_names
                SET username = %(username)s
                WHERE user_id = %(uid)s AND username IS DISTINCT FROM %(username)s;

                         INSERT INTO user_names(user_id, date, username, display_name)
                             VALUES (%(uid)s, current_timestamp, %(username)s, %(display_name)s);
                         ]
[parameters: {'username': '@fokioff', 'uid': 829706162, 'display_name': 'pavlik'}]
(Background on this error at: https://sqlalche.me/e/20/f405)
dinosaurtirex commented 1 year ago

I will try to fix it and make PR

dinosaurtirex commented 1 year ago

Yep i fix that

mkdryden commented 1 year ago

Thanks, I will take a proper look soon, but I see what I did wrong and your solution seems fine (and I need to add that to the tests). I see what I messed up with the first one and it's an easy fix. I just missed an if statement when I made the backup store optional.

mkdryden commented 1 year ago

Fixed in 552f65dcf67a1559b266d171484607070e8ffb07

dinosaurtirex commented 1 year ago

Thanks, I will take a proper look soon, but I see what I did wrong and your solution seems fine (and I need to add that to the tests). I see what I messed up with the first one and it's an easy fix. I just missed an if statement when I made the backup store optional.

Thank you for providing this bot and making it open source. Despite encountering some issues, such as the lack of a one-click solution with Docker, it remains the best open-source Telegram chat analysis bot. The graphical information and algorithms are incredibly useful and save a lot of time for developers like me. I appreciate this project. Thanks