ptbstats.SimpleStats#

class ptbstats.SimpleStats(command, check_update)#

Simple implementation of ptbstats.BaseStats collecting records per day and user. The command callback will run non-blocking.

Parameters:
command#

The command that produces the statistics associated with this instance.

records#

For each datetime.date, the dict value is an object with two attributes user_ids and queries. user_ids is a set of all user ids that where recorded on that day. queries is the total amount of recorded queries on that day.

check_update(update)#

See ptbstats.BaseStats.check_update().

Return type:

Optional[bool]

load_data(application)#

Loads the data stored by store_data(). Assumes that context.bot_data is a dict and loads the data from application.bot_data['SimpleStats']. Override to customize the behavior.

Return type:

None

async process_update(update)#

Records the update.

Parameters:

update (Update) – The telegram.Update.

Return type:

None

async reply_statistics(update, context)#

Sends one HTML-file with the two graphs of number of users per day and number of queries per day as reply.

Parameters:
Return type:

None

store_data(context)#

Persists records. Assumes that context.bot_data is a dict and stores the data in context.bot_data['SimpleStats'][self.command]. Override to customize the behavior.

Return type:

None