ptbstats package#

ptbstats.set_application(application)#

Set the application to be used with ptbstats.

Parameters:

application (Application) – The telegram.ext.Application.

Return type:

None

ptbstats.register_stats(stats, admin_id=None, stats_group=None, command_group=None)#

Register a statistics instance. This will register two handlers on the application set with set_application():

  1. The stats handler. By default, each of those handlers will get it’s own group, starting with -10e10. That should be enough to not interfere with your other handlers.

  2. A telegram.ext.CommandHandler that will listen for command and call stats.reply_statistics to report the current statistics. By default, all those command handlers will be added to group 0. If you register the statistics before your other handlers, that should usually be enough to make sure that the command will not be caught by other handlers.

Moreover, makes sure hat persisted data is loaded into the statistics instances.

Parameters:
  • stats (BaseStats) – The statistics instance to be added.

  • admin_id (Union[int, Sequence[int]]) – Optional. If passed, only the admin/s with the corresponding user ids will be allowed to query the statistics.

  • stats_group (int) – Optional. The group to register the statistics handler to instead of the default.

  • command_group (int) – Optional. The group te register the command handler to instead of the default.

Return type:

None