CallbackQueryHandler doesn't return user_data when set to True
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am trying to use buttons with my Telegram bot in order to get user input. One of the things I require to be passed on is the telegram userid but when using CallbackQueryHandler with pass_user_data set to Ture, I am only getting an empty dictionary returned?
Tried with debugger running but still can't see where I am going wrong. I am on Python 3.7.
In main():
dp = updater.dispatcher
dp.add_handler(CallbackQueryHandler(listbots, pattern='viewbots', pass_user_data=True))
def listbots(bot, update, user_data):
logging.debug('User_Data:')
logging.debug(user_data)
logging.debug('Update:')
logging.debug(update.message.from_user.id)
I'm expecting to see the user data for who clicked the button but instead I get nothing:
2019-01-04 20:31:46,474 - root - DEBUG - User_Data:
2019-01-04 20:31:46,474 - root - DEBUG - {}
2019-01-04 20:31:46,474 - root - DEBUG - Update:
2019-01-04 20:31:46,474 - telegram.ext.dispatcher - ERROR - An uncaught error was raised while processing the update
Traceback (most recent call last):
File "/Users/yogi/PycharmProjects/bottest/venv/lib/python3.7/site-packages/telegram/ext/dispatcher.py", line 279, in process_update
handler.handle_update(update, self)
File "/Users/yogi/PycharmProjects/bottest/venv/lib/python3.7/site-packages/telegram/ext/callbackqueryhandler.py", line 143, in handle_update
return self.callback(dispatcher.bot, update, **optional_args)
File "/Users/yogi/PycharmProjects/bottest/pb-userbot.py", line 179, in listbots
logging.debug(update.message.from_user.id)
AttributeError: 'NoneType' object has no attribute 'from_user'
python-3.x python-telegram-bot
add a comment |
I am trying to use buttons with my Telegram bot in order to get user input. One of the things I require to be passed on is the telegram userid but when using CallbackQueryHandler with pass_user_data set to Ture, I am only getting an empty dictionary returned?
Tried with debugger running but still can't see where I am going wrong. I am on Python 3.7.
In main():
dp = updater.dispatcher
dp.add_handler(CallbackQueryHandler(listbots, pattern='viewbots', pass_user_data=True))
def listbots(bot, update, user_data):
logging.debug('User_Data:')
logging.debug(user_data)
logging.debug('Update:')
logging.debug(update.message.from_user.id)
I'm expecting to see the user data for who clicked the button but instead I get nothing:
2019-01-04 20:31:46,474 - root - DEBUG - User_Data:
2019-01-04 20:31:46,474 - root - DEBUG - {}
2019-01-04 20:31:46,474 - root - DEBUG - Update:
2019-01-04 20:31:46,474 - telegram.ext.dispatcher - ERROR - An uncaught error was raised while processing the update
Traceback (most recent call last):
File "/Users/yogi/PycharmProjects/bottest/venv/lib/python3.7/site-packages/telegram/ext/dispatcher.py", line 279, in process_update
handler.handle_update(update, self)
File "/Users/yogi/PycharmProjects/bottest/venv/lib/python3.7/site-packages/telegram/ext/callbackqueryhandler.py", line 143, in handle_update
return self.callback(dispatcher.bot, update, **optional_args)
File "/Users/yogi/PycharmProjects/bottest/pb-userbot.py", line 179, in listbots
logging.debug(update.message.from_user.id)
AttributeError: 'NoneType' object has no attribute 'from_user'
python-3.x python-telegram-bot
add a comment |
I am trying to use buttons with my Telegram bot in order to get user input. One of the things I require to be passed on is the telegram userid but when using CallbackQueryHandler with pass_user_data set to Ture, I am only getting an empty dictionary returned?
Tried with debugger running but still can't see where I am going wrong. I am on Python 3.7.
In main():
dp = updater.dispatcher
dp.add_handler(CallbackQueryHandler(listbots, pattern='viewbots', pass_user_data=True))
def listbots(bot, update, user_data):
logging.debug('User_Data:')
logging.debug(user_data)
logging.debug('Update:')
logging.debug(update.message.from_user.id)
I'm expecting to see the user data for who clicked the button but instead I get nothing:
2019-01-04 20:31:46,474 - root - DEBUG - User_Data:
2019-01-04 20:31:46,474 - root - DEBUG - {}
2019-01-04 20:31:46,474 - root - DEBUG - Update:
2019-01-04 20:31:46,474 - telegram.ext.dispatcher - ERROR - An uncaught error was raised while processing the update
Traceback (most recent call last):
File "/Users/yogi/PycharmProjects/bottest/venv/lib/python3.7/site-packages/telegram/ext/dispatcher.py", line 279, in process_update
handler.handle_update(update, self)
File "/Users/yogi/PycharmProjects/bottest/venv/lib/python3.7/site-packages/telegram/ext/callbackqueryhandler.py", line 143, in handle_update
return self.callback(dispatcher.bot, update, **optional_args)
File "/Users/yogi/PycharmProjects/bottest/pb-userbot.py", line 179, in listbots
logging.debug(update.message.from_user.id)
AttributeError: 'NoneType' object has no attribute 'from_user'
python-3.x python-telegram-bot
I am trying to use buttons with my Telegram bot in order to get user input. One of the things I require to be passed on is the telegram userid but when using CallbackQueryHandler with pass_user_data set to Ture, I am only getting an empty dictionary returned?
Tried with debugger running but still can't see where I am going wrong. I am on Python 3.7.
In main():
dp = updater.dispatcher
dp.add_handler(CallbackQueryHandler(listbots, pattern='viewbots', pass_user_data=True))
def listbots(bot, update, user_data):
logging.debug('User_Data:')
logging.debug(user_data)
logging.debug('Update:')
logging.debug(update.message.from_user.id)
I'm expecting to see the user data for who clicked the button but instead I get nothing:
2019-01-04 20:31:46,474 - root - DEBUG - User_Data:
2019-01-04 20:31:46,474 - root - DEBUG - {}
2019-01-04 20:31:46,474 - root - DEBUG - Update:
2019-01-04 20:31:46,474 - telegram.ext.dispatcher - ERROR - An uncaught error was raised while processing the update
Traceback (most recent call last):
File "/Users/yogi/PycharmProjects/bottest/venv/lib/python3.7/site-packages/telegram/ext/dispatcher.py", line 279, in process_update
handler.handle_update(update, self)
File "/Users/yogi/PycharmProjects/bottest/venv/lib/python3.7/site-packages/telegram/ext/callbackqueryhandler.py", line 143, in handle_update
return self.callback(dispatcher.bot, update, **optional_args)
File "/Users/yogi/PycharmProjects/bottest/pb-userbot.py", line 179, in listbots
logging.debug(update.message.from_user.id)
AttributeError: 'NoneType' object has no attribute 'from_user'
python-3.x python-telegram-bot
python-3.x python-telegram-bot
asked Jan 4 at 10:36
YogiBearYogiBear
12
12
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54037275%2fcallbackqueryhandler-doesnt-return-user-data-when-set-to-true%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54037275%2fcallbackqueryhandler-doesnt-return-user-data-when-set-to-true%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown