ptbstats.SimpleStats

class ptbstats.SimpleStats(command, check_update)

Bases: Generic[telegram.ext.handler.UT], abc.ABC

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

command

The command that produces the statistics associated with this instance.

records

For each datetime.date, the dict value is a dict, containing for each user the number of recorded inline queries.

Parameters
check_update(update)

This method is called to determine if an update should be processed by this statistics instance. It must always be overridden.

Note

You can imitate Filters by this method by something like:

def check_update(self, update: Update):
    return update.effective_message and (Filters.text | Filters.sticker)(update)
Parameters

update (telegram.Update) – The update to be tested.

Return type

Optional[bool]

Returns

Either None or False if the update should not be handled, True otherwise.

fill()

Fills empty dates since the last record with zeros.

Return type

None

persistent_data()

Persists records.

Return type

Dict[str, Any]

Returns

Dict[str, Any]

process_update(update)

Counts the number of queries per user and day.

Parameters

update (Update) – The telegram.Update.

Return type

None

reply_statistics(update, context)

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

Parameters
Return type

None