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.

Overview

telegram-stats-bot

PyPi Package Version Supported Python versions GitHub Commit Activity LGPLv3 License

Telegram-stats-bot is 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.

Bot conversation example

Table of contents

Introduction

This software is intended to be run on a server, handling updates for a bot user with a single bot per channel (multi-channel support could be added at some point if there is interest), using the excellent Python-telegram-bot library.

The bot is still in active development but at the moment, it features:

  • Message logging to Postgresql database with optional JSON file backup
  • Statistics output for users in group as Telegram messages, with optional filtering by date or limiting to the querying user. Some statistics are more useful than others, but they are mainly intended to be fun for users to play with.
    • Tables:
      • Most active users
      • A user's message time correlation with other users
      • A user's median message time difference with other users
    • Plots:
      • Message activity by hour of day
      • Message activity by day of week
      • Message activity over the week by hour and day
      • Message activity history

Basic Requirements

  • Python 3.8+
  • A Telegram bot token with privacy mode disabled (needed to log messages)
    • See here for details
  • Postgresql (Tested with 12.3, but there shouldn't be anything that won't work with 9.4 or up)
    • This can be on a different system than telegram-stats-bot and requires either table creation permissions on a database or database can be pre-initialized following the setup in db.py

Installation

The easiest way to install or upgrade is with pip:

$ pip install telegram-stats-bot --upgrade

Or you can install the latest git version using poetry (installed to Python 3.7 or later):

$ git clone https://github.com/mkdryden/telegram-stats-bot.git
$ poetry install

Installing directly with setup.py should also work from the Pypi sdist (but why?).

Docker

A Docker image is available under mkdryden/telegram-stats-bot and a sample docker-compose.yml is in the root of the repository including database setup. Be sure to set the TZ, BOT_TOKEN, and CHAT_ID environment variable appropriately in your docker-run command or the docker-compose.yml file.

Setup

Once installed, you can run the bot by calling the main module with a few required arguments:

$ python -m telegram_stats_bot.main BOT_TOKEN CHAT_ID POSTGRESQL_URL
  • BOT_TOKEN: Your bot's token e.g., 110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw
  • CHAT_ID: The chat id to monitor (will be a large integer, possibly negative, if unknown, set to 0 and see below)
  • POSTGRESQL_URL: Connection information in the form: postgresql://USERNAME:PASSWORD@ADDRESS/DB_NAME
    • if DB_NAME exists, there must not be tables called messages_utc, user_events, or user_names with incorrect columns

Two optional arguments exist as well:

  • json-path: Specifying a path here will log messages to json files in addition to the database. If only a prefix is specified, they will be saved under that prefix in your platform's preferred app data directory. This was mostly for development purposes and is not necessary in normal use.
  • tz: Specify a tz database time zone string here (e.g., America/New_York) to return statistics queries in this time zone. (Defaults to Etc./UTC)

A complete command might look like:

$ python -m telegram_stats_bot.main --tz="America/Toronto" "110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw" "postgresql://telegram:CoolPassword@localhost/telegram_bot"

On startup, the bot will attempt to create the database and tables, if they do not already exist. If you do not know the chat's id and have set it to 0 as mentioned above, you can send the /chatid command inside the group, and the bot will reply with it, then restart the bot with the id. If you have forgotten to disable privacy mode, an error will be logged in the terminal.

The bot will now log all messages in the group, but will only respond to users who have sent a message that has been logged previously (and this list is only updated once an hour, so if you're impatient, you can restart the bot after you've sent a message to trigger the update). You can see if messages are being logged correctly by reviewing the terminal output. You should see a line like 2020-06-04 02:08:39,212 - __main__ - INFO - 8, whenever a message is logged.

Fetching Stats

To fetch stats, simply message the bot, either inside the group being logged, or in a direct message, using the /stats command. /stats with no arguments prints the table of most active users and other statistics are available through various subcommands. All commands are documented and the built in help can be displayed with /stats -h or stats <subcommand> -h.

Most commands have optional arguments that change the behaviour of the output. Nearly all have:

  • -start and -end followed by a timestamp (e.g., 2019, 2019-01, 2019-01-01, "2019-01-01 14:21") specify the range of data to fetch, otherwise all available data will be used. Either or both options can be given.
  • -lquery followed by a lexical query (using Postgres' tsquery syntax) limits results to matching messages.
  • -me calculates statistics for the user sending the command, rather than all chat users.

Sample outputs of each available subcommand follow.

counts

/stats counts returns a list of the most active users in the group.

              User  Total Messages  Percent
        @ACoolUser           42150      7.0
        @NumberOne           37370      6.2
 @WinstonChurchill           32668      5.4
          @AAAAAAA           32134      5.4
@WhereAreMyManners           30481      5.1
@TheWorstOfTheBest           28705      4.8

hours

/stats hours returns a plot of message frequency for the hours of the day.

Example of hours plot

days

/stats days returns a plot of message frequency for the days of the week.

Example of days plot

week

/stats week returns a plot of total messages over the data period by day of week and hour of day.

Example of week plot

history

/stats history returns a plot of messages versus date.

Example of history plot

titles

/stats titles returns a plot of group titles over time.

Example of title history plot

user

/stats user returns basic statistics for the user.

Messages sent: 16711
Average messages per day: 12.31
First message was 1357.22 days ago.
Usernames on record: 3
Average username lifetime: 452.41 days

joined on 2017-10-01 16:11:08-04:00

corr

/stats corr returns a list of users with the highest and lowest message time correlations with the requesting user.

User Correlations for @TheManWhoWasThursday
HIGHEST CORRELATION:
@MyGoodFriend         0.335
@Rawr                 0.302
@MangesUnePoutine     0.284
@GreenBlood           0.251
@TooMuchVacuum        0.235

LOWEST CORRELATION:
@Shiny                0.146
@BlueDog              0.142
@CoolCat              0.122
@EatMe                0.116
@JustPassingBy        0.106

delta

/stats delta returns a list of users with the shortest differences in message times with the requesting user.

Median message delays for @KingLeer and:
@PolyamorousPasta     00:03:23
@AggressiveArgon      00:04:43
@AdjectiveNoun        00:08:27
@SuperSalad           00:09:05
@ABoredProgrammer     00:09:06

types

/stats types returns a table of messages by type, comparing the requesting user with the full group.

Messages by type, @AUser vs group:
      type  Group Count  Group Percent  User Count  User Percent
      text     528813.0           88.3     13929.0          83.4
   sticker      34621.0            5.8      1226.0           7.3
     photo      25995.0            4.3      1208.0           7.2
 animation       6983.0            1.2       274.0           1.6
     video       1325.0            0.2        48.0           0.3
     voice        475.0            0.1         2.0           0.0
  location        252.0            0.0         2.0           0.0
video_note         84.0            0.0         1.0           0.0
     audio         62.0            0.0         1.0           0.0
      poll         29.0            0.0         1.0           0.0
  document          1.0            0.0         1.0           0.0
     Total     598640.0          100.0     16693.0         100.0

words

/stats words returns a table of the most commonly used lexemes

Most frequently used lexemes:
    Lexeme  Messages  Uses
      like      1265  1334
      well       753   765
    actual       628   645
      make       600   619
      yeah       609   609
      mean       544   553
     thing       473   490
    realli       472   482
    though       467   470
     peopl       415   445
     think       425   433
      know       403   409
      need       396   408
      time       371   389
      want       354   371
     would       345   366
      much       345   357
   probabl       348   356
      even       331   338
     stuff       318   332

random

/stats random prints a random message from the database.

The Future

Telegram-stats-bot is a work in progress. New stats will be added, but no guarantees that the database structure will stay constant if Telegram's message structure changes or I need to change something to make a new statistic work.

License

Telegram-stats-bot is free software: You can redistribute it and/or modify it under the terms of the GNU General Public License v3.0 or later. Derivative works must also be redistributed under the GPL v3 or later.

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

    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' (...

    bug 
    opened by hndrk-themer 6
  • Importing historical stats

    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?

    enhancement 
    opened by 0x464e 4
  • Somehow some words are changed in /stats words

    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

    opened by hndrk-themer 2
  • build(deps): bump certifi from 2021.10.8 to 2022.12.7

    build(deps): bump certifi from 2021.10.8 to 2022.12.7

    Bumps certifi from 2021.10.8 to 2022.12.7.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • I GET THIS ERROR WHILE CREATING A TELEGRAM BOT. SOMEONE PLEASE HELP ME 😭

    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)

    duplicate 
    opened by ayushman979 1
  • build(deps): bump pillow from 9.0.1 to 9.3.0

    build(deps): bump pillow from 9.0.1 to 9.3.0

    Bumps pillow from 9.0.1 to 9.3.0.

    Release notes

    Sourced from pillow's releases.

    9.3.0

    https://pillow.readthedocs.io/en/stable/releasenotes/9.3.0.html

    Changes

    ... (truncated)

    Changelog

    Sourced from pillow's changelog.

    9.3.0 (2022-10-29)

    • Limit SAMPLESPERPIXEL to avoid runtime DOS #6700 [wiredfool]

    • Initialize libtiff buffer when saving #6699 [radarhere]

    • Inline fname2char to fix memory leak #6329 [nulano]

    • Fix memory leaks related to text features #6330 [nulano]

    • Use double quotes for version check on old CPython on Windows #6695 [hugovk]

    • Remove backup implementation of Round for Windows platforms #6693 [cgohlke]

    • Fixed set_variation_by_name offset #6445 [radarhere]

    • Fix malloc in _imagingft.c:font_setvaraxes #6690 [cgohlke]

    • Release Python GIL when converting images using matrix operations #6418 [hmaarrfk]

    • Added ExifTags enums #6630 [radarhere]

    • Do not modify previous frame when calculating delta in PNG #6683 [radarhere]

    • Added support for reading BMP images with RLE4 compression #6674 [npjg, radarhere]

    • Decode JPEG compressed BLP1 data in original mode #6678 [radarhere]

    • Added GPS TIFF tag info #6661 [radarhere]

    • Added conversion between RGB/RGBA/RGBX and LAB #6647 [radarhere]

    • Do not attempt normalization if mode is already normal #6644 [radarhere]

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • build(deps): bump pillow from 8.3.2 to 9.0.0

    build(deps): bump pillow from 8.3.2 to 9.0.0

    Bumps pillow from 8.3.2 to 9.0.0.

    Release notes

    Sourced from pillow's releases.

    9.0.0

    https://pillow.readthedocs.io/en/stable/releasenotes/9.0.0.html

    Changes

    ... (truncated)

    Changelog

    Sourced from pillow's changelog.

    9.0.0 (2022-01-02)

    • Restrict builtins for ImageMath.eval(). CVE-2022-22817 #5923 [radarhere]

    • Ensure JpegImagePlugin stops at the end of a truncated file #5921 [radarhere]

    • Fixed ImagePath.Path array handling. CVE-2022-22815, CVE-2022-22816 #5920 [radarhere]

    • Remove consecutive duplicate tiles that only differ by their offset #5919 [radarhere]

    • Improved I;16 operations on big endian #5901 [radarhere]

    • Limit quantized palette to number of colors #5879 [radarhere]

    • Fixed palette index for zeroed color in FASTOCTREE quantize #5869 [radarhere]

    • When saving RGBA to GIF, make use of first transparent palette entry #5859 [radarhere]

    • Pass SAMPLEFORMAT to libtiff #5848 [radarhere]

    • Added rounding when converting P and PA #5824 [radarhere]

    • Improved putdata() documentation and data handling #5910 [radarhere]

    • Exclude carriage return in PDF regex to help prevent ReDoS #5912 [hugovk]

    • Fixed freeing pointer in ImageDraw.Outline.transform #5909 [radarhere]

    • Added ImageShow support for xdg-open #5897 [m-shinder, radarhere]

    • Support 16-bit grayscale ImageQt conversion #5856 [cmbruns, radarhere]

    • Convert subsequent GIF frames to RGB or RGBA #5857 [radarhere]

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • Why is this program that enjoyable?

    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!

    opened by indicozy 1
  • build(deps): bump cryptography from 3.0 to 3.2

    build(deps): bump cryptography from 3.0 to 3.2

    Bumps cryptography from 3.0 to 3.2.

    Changelog

    Sourced from cryptography's changelog.

    3.2 - 2020-10-25

    
    * **SECURITY ISSUE:** Attempted to make RSA PKCS#1v1.5 decryption more constant
      time, to protect against Bleichenbacher vulnerabilities. Due to limitations
      imposed by our API, we cannot completely mitigate this vulnerability and a
      future release will contain a new API which is designed to be resilient to
      these for contexts where it is required. Credit to **Hubert Kario** for
      reporting the issue. *CVE-2020-25659*
    * Support for OpenSSL 1.0.2 has been removed. Users on older version of OpenSSL
      will need to upgrade.
    * Added basic support for PKCS7 signing (including SMIME) via
      :class:`~cryptography.hazmat.primitives.serialization.pkcs7.PKCS7SignatureBuilder`.
    

    .. _v3-1-1:

    3.1.1 - 2020-09-22

    • Updated Windows, macOS, and manylinux wheels to be compiled with OpenSSL 1.1.1h.

    .. _v3-1:

    3.1 - 2020-08-26

    
    * **BACKWARDS INCOMPATIBLE:** Removed support for ``idna`` based
      :term:`U-label` parsing in various X.509 classes. This support was originally
      deprecated in version 2.1 and moved to an extra in 2.5.
    * Deprecated OpenSSL 1.0.2 support. OpenSSL 1.0.2 is no longer supported by
      the OpenSSL project. The next version of ``cryptography`` will drop support
      for it.
    * Deprecated support for Python 3.5. This version sees very little use and will
      be removed in the next release.
    * ``backend`` arguments to functions are no longer required and the
      default backend will automatically be selected if no ``backend`` is provided.
    * Added initial support for parsing certificates from PKCS7 files with
      :func:`~cryptography.hazmat.primitives.serialization.pkcs7.load_pem_pkcs7_certificates`
      and
      :func:`~cryptography.hazmat.primitives.serialization.pkcs7.load_der_pkcs7_certificates`
      .
    * Calling ``update`` or ``update_into`` on
      :class:`~cryptography.hazmat.primitives.ciphers.CipherContext` with ``data``
      longer than 2\ :sup:`31` bytes no longer raises an ``OverflowError``. This
      also resolves the same issue in :doc:`/fernet`.
    

    .. _v3-0:

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • build(deps): bump pillow from 8.2.0 to 8.3.2

    build(deps): bump pillow from 8.2.0 to 8.3.2

    Bumps pillow from 8.2.0 to 8.3.2.

    Release notes

    Sourced from pillow's releases.

    8.3.2

    https://pillow.readthedocs.io/en/stable/releasenotes/8.3.2.html

    Security

    • CVE-2021-23437 Raise ValueError if color specifier is too long [hugovk, radarhere]

    • Fix 6-byte OOB read in FliDecode [wiredfool]

    Python 3.10 wheels

    • Add support for Python 3.10 #5569, #5570 [hugovk, radarhere]

    Fixed regressions

    • Ensure TIFF RowsPerStrip is multiple of 8 for JPEG compression #5588 [kmilos, radarhere]

    • Updates for ImagePalette channel order #5599 [radarhere]

    • Hide FriBiDi shim symbols to avoid conflict with real FriBiDi library #5651 [nulano]

    8.3.1

    https://pillow.readthedocs.io/en/stable/releasenotes/8.3.1.html

    Changes

    8.3.0

    https://pillow.readthedocs.io/en/stable/releasenotes/8.3.0.html

    Changes

    ... (truncated)

    Changelog

    Sourced from pillow's changelog.

    8.3.2 (2021-09-02)

    • CVE-2021-23437 Raise ValueError if color specifier is too long [hugovk, radarhere]

    • Fix 6-byte OOB read in FliDecode [wiredfool]

    • Add support for Python 3.10 #5569, #5570 [hugovk, radarhere]

    • Ensure TIFF RowsPerStrip is multiple of 8 for JPEG compression #5588 [kmilos, radarhere]

    • Updates for ImagePalette channel order #5599 [radarhere]

    • Hide FriBiDi shim symbols to avoid conflict with real FriBiDi library #5651 [nulano]

    8.3.1 (2021-07-06)

    • Catch OSError when checking if fp is sys.stdout #5585 [radarhere]

    • Handle removing orientation from alternate types of EXIF data #5584 [radarhere]

    • Make Image.array take optional dtype argument #5572 [t-vi, radarhere]

    8.3.0 (2021-07-01)

    • Use snprintf instead of sprintf. CVE-2021-34552 #5567 [radarhere]

    • Limit TIFF strip size when saving with LibTIFF #5514 [kmilos]

    • Allow ICNS save on all operating systems #4526 [baletu, radarhere, newpanjing, hugovk]

    • De-zigzag JPEG's DQT when loading; deprecate convert_dict_qtables #4989 [gofr, radarhere]

    • Replaced xml.etree.ElementTree #5565 [radarhere]

    ... (truncated)

    Commits
    • 8013f13 8.3.2 version bump
    • 23c7ca8 Update CHANGES.rst
    • 8450366 Update release notes
    • a0afe89 Update test case
    • 9e08eb8 Raise ValueError if color specifier is too long
    • bd5cf7d FLI tests for Oss-fuzz crash.
    • 94a0cf1 Fix 6-byte OOB read in FliDecode
    • cece64f Add 8.3.2 (2021-09-02) [CI skip]
    • e422386 Add release notes for Pillow 8.3.2
    • 08dcbb8 Pillow 8.3.2 supports Python 3.10 [ci skip]
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • build(deps): bump pillow from 8.0.1 to 8.1.1

    build(deps): bump pillow from 8.0.1 to 8.1.1

    Bumps pillow from 8.0.1 to 8.1.1.

    Release notes

    Sourced from pillow's releases.

    8.1.1

    https://pillow.readthedocs.io/en/stable/releasenotes/8.1.1.html

    8.1.0

    https://pillow.readthedocs.io/en/stable/releasenotes/8.1.0.html

    Changes

    Dependencies

    Deprecations

    ... (truncated)

    Changelog

    Sourced from pillow's changelog.

    8.1.1 (2021-03-01)

    • Use more specific regex chars to prevent ReDoS. CVE-2021-25292 [hugovk]

    • Fix OOB Read in TiffDecode.c, and check the tile validity before reading. CVE-2021-25291 [wiredfool]

    • Fix negative size read in TiffDecode.c. CVE-2021-25290 [wiredfool]

    • Fix OOB read in SgiRleDecode.c. CVE-2021-25293 [wiredfool]

    • Incorrect error code checking in TiffDecode.c. CVE-2021-25289 [wiredfool]

    • PyModule_AddObject fix for Python 3.10 #5194 [radarhere]

    8.1.0 (2021-01-02)

    • Fix TIFF OOB Write error. CVE-2020-35654 #5175 [wiredfool]

    • Fix for Read Overflow in PCX Decoding. CVE-2020-35653 #5174 [wiredfool, radarhere]

    • Fix for SGI Decode buffer overrun. CVE-2020-35655 #5173 [wiredfool, radarhere]

    • Fix OOB Read when saving GIF of xsize=1 #5149 [wiredfool]

    • Makefile updates #5159 [wiredfool, radarhere]

    • Add support for PySide6 #5161 [hugovk]

    • Use disposal settings from previous frame in APNG #5126 [radarhere]

    • Added exception explaining that repr_png saves to PNG #5139 [radarhere]

    • Use previous disposal method in GIF load_end #5125 [radarhere]

    ... (truncated)

    Commits
    • 741d874 8.1.1 version bump
    • 179cd1c Added 8.1.1 release notes to index
    • 7d29665 Update CHANGES.rst [ci skip]
    • d25036f Credits
    • 973a4c3 Release notes for 8.1.1
    • 521dab9 Use more specific regex chars to prevent ReDoS
    • 8b8076b Fix for CVE-2021-25291
    • e25be1e Fix negative size read in TiffDecode.c
    • f891baa Fix OOB read in SgiRleDecode.c
    • cbfdde7 Incorrect error code checking in TiffDecode.c
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • json import: Pandas error

    json import: Pandas error

        I faced such an error when importing simple json with 75 messages
    

    iTerm2 2023-01-03 at 22 50 53@2x

    @mkdryden is this something you are are mentioning in this issue?

    Originally posted by @eiger8 in https://github.com/mkdryden/telegram-stats-bot/issues/17#issuecomment-1370212737

    bug 
    opened by mkdryden 0
  • import script causes db issues

    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.

    bug 
    opened by mkdryden 4
  • Titles plot fails for some image dimensions

    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
    
    bug 
    opened by mkdryden 0
  • Are you planning to update it to work in the newly implemented

    Are you planning to update it to work in the newly implemented "topics" feature?

    As telegram introduced the topics feature the bot wont answer no more if you call a command in a topic. it still counts tho but just can answer in DM.

    enhancement 
    opened by hndrk-themer 1
Releases(v0.6.4)
  • v0.6.4(Feb 27, 2022)

  • v0.6.3(Jan 13, 2022)

    Changed

    • Titles plot uses seconds resolution with -duration option

    Fixed

    • Fix database creation code for immutable SQLAlchemy 1.4 URLs
    • Titles plot considers time zone correctly for current time. (Prevents negative bars in titles plot with -duration option)
    • Package versions bumped to allow Python 3.10 compatibility

    Full Changelog: https://github.com/mkdryden/telegram-stats-bot/compare/v0.6.2...v0.6.3

    Source code(tar.gz)
    Source code(zip)
  • v0.6.2(Nov 12, 2021)

    Changed

    • Changed build backend to poetry-core so that all of poetry doesn't need to be installed just to do a PEP 517 build (e.g. pip)

    Full Changelog: https://github.com/mkdryden/telegram-stats-bot/compare/v0.6.1...v0.6.2

    Source code(tar.gz)
    Source code(zip)
  • v0.6.1(Nov 7, 2021)

  • v0.6.0(Aug 1, 2021)

  • v0.3.0(Oct 7, 2020)

    Fixed

    • Correctly escape all reserved markdown characters and markdown links

    Added

    • Print a random message from the log /stats random
    • Allow sorting title history plot by duration
    Source code(tar.gz)
    Source code(zip)
  • v0.2.0(Jun 16, 2020)

    Added

    • Message type statistics /stats types
    • Group title history plot /stats titles

    Fixed

    • Example images were missing in pypi distributions
    • Git install instructions were incorrect
    • Example images now .png instead of .jpg
    Source code(tar.gz)
    Source code(zip)
  • v0.1.1(Jun 6, 2020)

Owner
null
A Bot Telegram Anti Users Channel to automatic ban users who using channel to send message in group.

Tg_Anti_UsersChannel A Bot Telegram Anti Users Channel to automatic ban users who using channel to send message in group. Features: Automatic ban Whit

idzeroid 6 Dec 26, 2021
This is a scalable system that reads messages from public Telegram channels using Telethon and stores the data in a PostgreSQL database.

This is a scalable system that reads messages from public Telegram channels using Telethon and stores the data in a PostgreSQL database. Its original intention is to monitor cryptocurrency related channels, but it can be configured to read any Telegram data that is accessible through the API.

Greg 3 Jun 7, 2022
Discord bot code to stop users that are scamming with fake messages of free discord nitro on servers in order to steal users accounts.

AntiScam Discord bot code to stop users that are scamming with fake messages of free discord nitro on servers in order to steal users accounts. How to

H3cJP 94 Dec 15, 2022
A discord Server Bot made with Python, This bot helps people feel better by inspiring them with motivational quotes or by responding with a great message, also the users of the server can create custom messages by telling the bot with Commands.

A discord Server Bot made with Python, This bot helps people feel better by inspiring them with motivational quotes or by responding with a great message, also the users of the server can create custom messages by telling the bot with Commands.

Aran 1 Oct 13, 2021
szrose is an all in one group management bot made for managing your group effectively with some advance security tools & Suit For All Your Needs ❤️

szrose is an all in one group management bot made for managing your group effectively with some advance security tools & Suit For All Your Needs ❤️

szsupunma 93 Jan 7, 2023
This is a telegram bot hosted by a Raspberry Pi equipped with a temperature and humidity sensor. The bot is capable of sending plots and readings.

raspy-temperature-bot This is a telegram bot hosted by a Raspberry Pi equipped with a temperature and humidity sensor. The bot is capable of sending p

null 31 May 22, 2022
My personal template for a discord bot, including an asynchronous database and colored logging :)

My personal template for a discord bot, including an asynchronous database and colored logging :)

Timothy Pidashev 9 Dec 24, 2022
A Telegram AntiChannel bot to ban users who using channel to send message in group

Anti-Channel-bot A Telegram AntiChannel bot to ban users who using channel to send message in group. BOT LINK: Features: Automatic ban Whitelist Unban

Jigar varma 36 Oct 21, 2022
A Bot To Get Info Of Telegram messages , Media , Channel id Group ID etc.

Info-Bot A Bot To Get Info Of Telegram messages , Media , Channel id Group ID etc. Get Info Of Your And Messages , Channels , Groups ETC... How to mak

Vɪᴠᴇᴋ 23 Nov 12, 2022
DeleteAllBot - Telegram bot to delete all messages in a group

Delete All Bot A star ⭐ from you means a lot to me ! Telegram bot to delete all

Stark Bots 15 Dec 26, 2022
Optimus Prime - A modular Telegram group management and drive clone bot running on Python with sqlalchemy database

Optimus Prime Bot . ?? A modular Telegram group management and drive clone bot r

null 9 Jun 1, 2022
An anime themed telegram group management bot based on sqlalchemy database running on python3.

Kazuko Robot A Telegram Python bot running on python3 forked with saitama and DiasyX with a sqlalchemy database and an entirely themed persona to make

heyaaman 22 Dec 7, 2022
Asad Alexa VC Bot Is A Telegram Bot Project That's Allow You To Play Audio And Video Music On Telegram Voice Chat Group.

Asad Alexa VC Bot Is A Telegram Bot Project That's Allow You To Play Audio And Video Music On Telegram Voice Chat Group.

Dr Asad Ali 6 Jun 20, 2022
This is a simple program that uses Python and pyTwitchAPI to retrieve the list of users in a streamer's chat and then checks each one of these users to see if they follow the broadcaster or not

This is a simple program that uses Python and pyTwitchAPI to retrieve the list of users in a streamer's chat and then checks each one of these users to see if they follow the broadcaster or not

RwinShow 57 Dec 18, 2022
this repo store a Awoesome telegram bot for protect from your large group from bot attack.

this repo store a Awoesome telegram bot for protect from your large group from bot attack.

Mehran Alam Beigi 2 Jul 22, 2022
veez music bot is a telegram music bot project, allow you to play music on voice chat group telegram.

?? Veez Music Bot Music bot for playing music on telegram voice chat group. Requirements ?? FFmpeg NodeJS nodesource.com Python 3.7+ PyTgCalls ?? Get

levina 143 Jun 19, 2022
An Telegram Bot By @AsmSafone To Stream Videos in Telegram Voice Chat. This is Also The Source Code of The Bot Which is Being Used In @SafoTheBot Group! ❤️

Telegram Video Player Bot (Beta) An Telegram Bot By @AsmSafone To Stream Videos in Telegram Voice Chat. Special Features Supports Live Streaming From

SAF ONE 206 Jan 3, 2023
Video Bot: an Advanced Telegram Bot that's allow you to play Video & Music on Telegram Group Video Chat

Video Bot is an Advanced Telegram Bot that's allow you to play Video & Music on

null 5 Jan 26, 2022