Telegram callback queries converter
This tiny package can help you parse the callback data request response for telegram bots.
pip install callbaker
There are two main functions that might be helpfull for you:
info_from_callback
get callback string and convert it to dict.
callback_from_info
combine dict into string prepared for callback.
Examples:
result = callback_from_info(info={"k1": "str", "k2": 2, "k3": None, "k4": False, "k5": (1, 2)})
print(result)
"&k1=str&k2=2&k3=None&k4=False&k5=(1, 2)"
result = info_from_callback(call_data="&key_1=value_1&key_2=value_2")
print(result)
{'key_1': 'value_1', 'key_2': 'value_2'}