ptbstats package#
- ptbstats.set_application(application)#
Set the application to be used with
ptbstats
.- Parameters:
application (
Application
) – Thetelegram.ext.Application
.- Return type:
- 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()
: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.A
telegram.ext.CommandHandler
that will listen forcommand
and callstats.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: