Git Product home page Git Product logo

telegram-stats-bot's Issues

Importing historical stats

Hi,

Nice application, seems really cool.
For me to use it though, I'd really need some ability to import past stats. I'm not seeing support for this being documented, so I'm assuming it's not built in. Could I manually do it somehow though?

I GET THIS ERROR WHILE CREATING A TELEGRAM BOT. SOMEONE PLEASE HELP ME 😭

raceback (most recent call last):
File "c:\Users\ayush\OneDrive\Desktop\tele\tele.py", line 2, in
from telegram.ext import *
File "C:\Users\ayush\AppData\Local\Programs\Python\Python311\Lib\site-packages\telegram\ext_init_.py", line 21, in
from .extbot import ExtBot
File "C:\Users\ayush\AppData\Local\Programs\Python\Python311\Lib\site-packages\telegram\ext\extbot.py", line 24, in
import telegram.bot
File "C:\Users\ayush\AppData\Local\Programs\Python\Python311\Lib\site-packages\telegram\bot.py", line 56, in
from telegram import (
ImportError: cannot import name 'Animation' from 'telegram' (C:\Users\ayush\AppData\Local\Programs\Python\Python311\Lib\site-packages\telegram_init_.py)

/stats user doesnt work no more

Hey, am running the latest docker image. Unfortunately the /stats user command is broken rn.

This is what the Error log looks like:

2023-04-17 17:11:45,690 - telegram.ext.dispatcher - ERROR - No error handlers are registered, logging exception.
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/telegram/ext/utils/promise.py", line 96, in run
self._result = self.pooled_function(*self.args, **self.kwargs)
File "/usr/src/app/telegram_stats_bot/main.py", line 169, in print_stats
context.bot.send_message(chat_id=update.effective_chat.id,
File "/usr/local/lib/python3.9/site-packages/telegram/bot.py", line 134, in decorator
result = func(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/telegram/bot.py", line 534, in send_message
return self._message( # type: ignore[return-value]
File "/usr/local/lib/python3.9/site-packages/telegram/ext/extbot.py", line 203, in _message
result = super()._message(
File "/usr/local/lib/python3.9/site-packages/telegram/bot.py", line 344, in _message
result = self._post(endpoint, data, timeout=timeout, api_kwargs=api_kwargs)
File "/usr/local/lib/python3.9/site-packages/telegram/bot.py", line 299, in _post
return self.request.post(
File "/usr/local/lib/python3.9/site-packages/telegram/utils/request.py", line 361, in post
result = self._request_wrapper(
File "/usr/local/lib/python3.9/site-packages/telegram/utils/request.py", line 279, in _request_wrapper
raise BadRequest(message)
telegram.error.BadRequest: Can't parse entities: can't find end of italic entity at byte offset 9

json import: ignore bot messages

Currently import script includes messages sent by the bot that are ignored during normal operation. Should include an argument to exclude these.

import script causes db issues

The import script introduced in b8b8eff (see #10) seems to be changing the types of columns in the db.
I think this has to do with using pandas to do the update.
Specifically it is breaking the user command because it is changing the user_id column to text from integer.

Feature Request: Allow for multiple chats

Most chat owners that would find this useful have multiple chats. i personally have a docker-compose stack of 38 of these containers running to gather statistics on a whole slew of chats i'm interested in, admin, etc. it'd be useful for the bot to support multiple chats in some manner

ImportError: cannot import name 'Animation' from 'telegram'

After running your bot like for over 7months without problem i cant start it anymore. I literally changed nothing.

I reinstalled like stated in readme, i even did the poetry way after i couldnt get it fixed, but nothing.

On Python 3.8:

ImportError: cannot import name 'TelegramError' from 'telegram' (....

on Python 3.9:

ImportError: cannot import name 'Animation' from 'telegram' (...

Usernames issue (not updating on import causing duplicated userID entries)

Hello @mkdryden

After importing the chat history the usernames are not updated by UserID accordingly, causing the stats to show not correctly (i.e. with empty fields).
Telegram 2023-10-24 at 20 40 43@2x

When the user appears in chat, and writes some messages the username gets updated (by UserID), but this action is leading to user record duplication
TablePlus 2023-10-24 at 21 55 37@2x

Here is stdout in container when running /stats corr
Safari 2023-10-24 at 21 57 26@2x

Question: how can i use this for multiple chats?

i'm using the docker version and its great for my community's general chat, but we have like ~30+ different topic chats and i need to get statistics on a few of them at the same time so i can better plan community events and stuff by seeing times people are active etc... how can i do this? should i list the CHAT_IDs? like -100XXXXXXX, -100XXXXXXX or should i copypaste the docker compose to run two bots on the same database?

Somehow some words are changed in /stats words

Hey im using the latest version of your awesome bot on Python 3.8.4 on a raspberry pi 3b+ with an extern postgres12. So far the bot is working well since yesterday and stats are collected. what ive noticed that the output of /stats words has some weird results. Ill give two examples:

Text written in Chat: beautiful
Stats output: beauti

or
Text written in Chat: widgy
Stats output: widgi

shorten usernames in /stats view (or display the displayname instead)?

Hey, sorry to bother you, but i love your bot so much lol.

So usually the /stats output isnt that good readable on mobile phones. Basically because long @usernames will make it look odd

photo_2023-04-18_10-33-17

in most cases the displayname from users is a bit shorter (just a nickname) so would it be possible to show that instead. and maybe add a max limit of .. idk .. 15 letters and then it shortens the name with [...] or sth. i dont mind changing the code by myself, as you might have noticed i also edited the column headers a bit to shorten them but this one long username messes with the look. And i am not that pro at coding.

Have a nice day! Thanks for the work on this one.

2 bugs

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)

Support to non-ascii-safe names

Hi, I have started using this this bot in a personal group of friends chat and we've noticed it completely mangles the name of one of them. His name happens to contain a ç and that character was completely removed from his logged entry.

I have investigated the code and I've stumbled upon the following line:

df['User'] = df['User'].str.replace(r'[^\x00-\x7F]|[@]', "", regex=True)  # Drop emoji and @

Which basically states it's dropping emoji and the @ symbol. Not sure why that's even necessary but it's doing way more than just dropping emojis, it's dropping everything that's outside ASCII range. So no latin-alphabet extensions like é ü ø æ, and no support at all for non-latin scripts like cyrillic, greek, arabic, chinese, etc...

Is there a particular reason for this line to exist?
Python and Postgres should support UTF8 just fine...

Why is this program that enjoyable?

Hello, I found some issue here. When I added this bot to my chat, I feel like this program is too good.

To replicate

  1. Add this bot for you chat
  2. Enjoy

I just wanted to send a letter of appreciation. I like this bot and I'm using it for ethical collection of data. Thanks for your open-source program!

Titles plot fails for some image dimensions

Apparently /stats titles fails for chats with a small number of titles, resulting in a weird shaped image:

telegram-stats-bot_1  | Traceback (most recent call last):
telegram-stats-bot_1  |   File "/usr/local/lib/python3.9/site-packages/telegram/ext/utils/promise.py", line 96, in run
telegram-stats-bot_1  |     self._result = self.pooled_function(*self.args, **self.kwargs)
telegram-stats-bot_1  |   File "/usr/src/app/telegram_stats_bot/main.py", line 173, in print_stats
telegram-stats-bot_1  |     context.bot.send_photo(chat_id=update.effective_chat.id, photo=image)
telegram-stats-bot_1  |   File "/usr/local/lib/python3.9/site-packages/telegram/bot.py", line 134, in decorator
telegram-stats-bot_1  |     result = func(*args, **kwargs)
telegram-stats-bot_1  |   File "/usr/local/lib/python3.9/site-packages/telegram/bot.py", line 753, in send_photo
telegram-stats-bot_1  |     return self._message(  # type: ignore[return-value]
telegram-stats-bot_1  |   File "/usr/local/lib/python3.9/site-packages/telegram/ext/extbot.py", line 203, in _message
telegram-stats-bot_1  |     result = super()._message(
telegram-stats-bot_1  |   File "/usr/local/lib/python3.9/site-packages/telegram/bot.py", line 344, in _message
telegram-stats-bot_1  |     result = self._post(endpoint, data, timeout=timeout, api_kwargs=api_kwargs)
telegram-stats-bot_1  |   File "/usr/local/lib/python3.9/site-packages/telegram/bot.py", line 299, in _post
telegram-stats-bot_1  |     return self.request.post(
telegram-stats-bot_1  |   File "/usr/local/lib/python3.9/site-packages/telegram/utils/request.py", line 359, in post
telegram-stats-bot_1  |     result = self._request_wrapper('POST', url, fields=data, **urlopen_kwargs)
telegram-stats-bot_1  |   File "/usr/local/lib/python3.9/site-packages/telegram/utils/request.py", line 279, in _request_wrapper
telegram-stats-bot_1  |     raise BadRequest(message)
telegram-stats-bot_1  | telegram.error.BadRequest: Photo_invalid_dimensions

Not working when connecting to my cloud db

python -m telegram_stats_bot.main BOT_TOKEN CHAT_ID POSTGRESQL_URL

When i run this command to connect my local machine it connects and works, but when connecting to my cloud db it just connected and doesn't respond to commands or doesn't read messages..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.