A
A
Alex_8882019-07-13 11:45:28
Python
Alex_888, 2019-07-13 11:45:28

Get jnson user id on callback_quey?

There is this piece of code

class MyTeleBot(TeleBot):
    def get_updates(self, *args, **kwargs):
        json_updates = apihelper.get_updates(self.token, *args, **kwargs)
        ret = []
        for ju in json_updates:
            if ju['message']['from']['id'] in banned_users:

works fine with simple messages, but needs to add work with calldata. Those. in this example, we get the user id in the string ['message']['from']['id'] , with calldata the 'message' key naturally does not work, because the 'callback_query' key.
How can I combine so that the function works for both methods?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex_888, 2019-07-13
@Alex_888

Question removed!
We just check whether the required key is in the dictionary and further depending on the result!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question