ytturi / MortDeGana_Bot

Bot for Fun
MIT License
5 stars 6 forks source link

Add metrics generator #16

Closed ytturi closed 3 years ago

ytturi commented 4 years ago

We need a metrics handler, tbd the final provider, probably to be sent to influxDB. For now, we want a new file within mel called metrics.py that we will use for all the metrics functionallities. In this file we will prepare the metrics according to the parameters, some from the context, and some will have defaults. I am thinking on something like:

generate_metric(data: List[Tuple[str,Union[int,float]]], send_datetime: datetime = datetime.now()) -> str

The expected output will follow the format:

<timestamp> <data>

Where data has the following format:

identifier0=value0,identifier1=value1...

With the previous values:

"12345678 count=1,group_id=123456"

Aside from that we will also need some data in order to store the metrics using the ChatID and the TelegramUser, those are extracted from the Context. We would like both methods in the utils.py

get_telegram_group_id(context: CallbackContext) -> int
get_telegram_user_id(context: CallbackContext) -> int