{"action":"created","comment":{"url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/comments/84955333","pull_request_review_id":5700194,"id":84955333,"diff_hunk":"@@ -0,0 +1,152 @@\n+#!/usr/bin/env python\n+# -*- coding: utf-8 -*-\n+#\n+# Simple Bot to reply to Telegram messages\n+# This program is dedicated to the public domain under the CC0 license.\n+\"\"\"\n+This Bot uses the Updater class to handle the bot.\n+\n+First, a few callback functions are defined. Then, those functions are passed to\n+the Dispatcher and registered at their respective places.\n+Then, the bot is started and runs until we press Ctrl-C on the command line.\n+\n+Usage:\n+Example of a bot-user conversation using ConversationHandler.\n+Send /start to initiate the conversation.\n+Press Ctrl-C on the command line or send a signal to the process to stop the\n+bot.\n+\"\"\"\n+\n+from telegram import (ReplyKeyboardMarkup)\n+from telegram.ext import (Updater, CommandHandler, MessageHandler, Filters, RegexHandler,\n+                          ConversationHandler)\n+\n+import logging\n+\n+# Enable logging\n+logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',\n+                    level=logging.INFO)\n+\n+logger = logging.getLogger(__name__)\n+\n+CHOOSING, TYPING_REPLY, TYPING_CHOICE = range(3)\n+\n+reply_keyboard = [['Age', 'Favourite colour'],\n+                  ['Number of siblings', 'Something else...'],\n+                  ['Done']]\n+markup = ReplyKeyboardMarkup(reply_keyboard, one_time_keyboard=True)\n+\n+\n+def facts_to_str(user_data):\n+    facts = list()\n+\n+    for key, value in user_data.items():\n+        facts.append('%s - %s' % (key, value))\n+\n+    return \"\\n\".join(facts).join(['\\n', '\\n'])\n+\n+\n+def start(bot, update):\n+    update.message.reply_text(\n+        \"Hi! My name is Doctor Botter. I will hold a more complex conversation with you. \"\n+        \"Why don't you tell me something about yourself?\",\n+        reply_markup=markup)\n+\n+    return CHOOSING\n+\n+\n+def regular_choice(bot, update, user_data):\n+    text = update.message.text\n+    user_data['choice'] = text\n+    update.message.reply_text('Your %s? Yes, I would love to hear about that!' % text.lower())\n+\n+    return TYPING_REPLY\n+\n+\n+def custom_choice(bot, update):\n+    update.message.reply_text('Alright, please send me the category first, '\n+                              'for example \"Most impressive skill\"')\n+\n+    return TYPING_CHOICE\n+\n+\n+def received_information(bot, update, user_data):\n+    text = update.message.text\n+    category = user_data['choice']\n+    user_data[category] = text\n+    del user_data['choice']\n+\n+    update.message.reply_text(\"Neat! Just so you know, this is what you already told me:\"\n+                              \"%s\"\n+                              \"You can tell me more, or change your opinion on something.\"\n+                              % facts_to_str(user_data),\n+                              reply_markup=markup)\n+\n+    return CHOOSING\n+\n+\n+def done(bot, update, user_data):\n+    if 'choice' in user_data:\n+        del user_data['choice']\n+\n+    update.message.reply_text(\"I learned these facts about you:\"\n+                              \"%s\"\n+                              \"Until next time!\" % facts_to_str(user_data))\n+\n+    user_data.clear()\n+    return ConversationHandler.END\n+\n+\n+def error(bot, update, error):\n+    logger.warn('Update \"%s\" caused error \"%s\"' % (update, error))\n+\n+\n+def main():\n+    # Create the Updater and pass it your bot's token.\n+    updater = Updater(\"TOKEN\")\n+\n+    # Get the dispatcher to register handlers\n+    dp = updater.dispatcher\n+\n+    # Add conversation handler with the states GENDER, PHOTO, LOCATION and BIO\n+    conv_handler = ConversationHandler(\n+        entry_points=[CommandHandler('start', start)],\n+\n+        states={\n+            CHOOSING: [RegexHandler('^(Age|Favourite colour|Number of siblings)$',\n+                                    regular_choice,\n+                                    pass_user_data=True),\n+                       RegexHandler('^Something else...$',\n+                                    custom_choice),\n+                       ],\n+\n+            TYPING_CHOICE: [MessageHandler([Filters.text],","path":"examples/conversationbot2.py","position":123,"original_position":123,"commit_id":"99826a6276f9d8308852252a83f1ecf201c82473","original_commit_id":"99826a6276f9d8308852252a83f1ecf201c82473","user":{"login":"jh0ker","id":3945220,"avatar_url":"https://avatars.githubusercontent.com/u/3945220?v=3","gravatar_id":"","url":"https://api.github.com/users/jh0ker","html_url":"https://github.com/jh0ker","followers_url":"https://api.github.com/users/jh0ker/followers","following_url":"https://api.github.com/users/jh0ker/following{/other_user}","gists_url":"https://api.github.com/users/jh0ker/gists{/gist_id}","starred_url":"https://api.github.com/users/jh0ker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jh0ker/subscriptions","organizations_url":"https://api.github.com/users/jh0ker/orgs","repos_url":"https://api.github.com/users/jh0ker/repos","events_url":"https://api.github.com/users/jh0ker/events{/privacy}","received_events_url":"https://api.github.com/users/jh0ker/received_events","type":"User","site_admin":false},"body":"On a second thought, I'll wait with that till the release\r\n","created_at":"2016-10-25T17:24:39Z","updated_at":"2016-10-25T17:24:40Z","html_url":"https://github.com/python-telegram-bot/python-telegram-bot/pull/436#discussion_r84955333","pull_request_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/436","_links":{"self":{"href":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/comments/84955333"},"html":{"href":"https://github.com/python-telegram-bot/python-telegram-bot/pull/436#discussion_r84955333"},"pull_request":{"href":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/436"}}},"pull_request":{"url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/436","id":88677130,"html_url":"https://github.com/python-telegram-bot/python-telegram-bot/pull/436","diff_url":"https://github.com/python-telegram-bot/python-telegram-bot/pull/436.diff","patch_url":"https://github.com/python-telegram-bot/python-telegram-bot/pull/436.patch","issue_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/issues/436","number":436,"state":"open","locked":false,"title":"Add pass_user_data and pass_chat_data to Handler","user":{"login":"jh0ker","id":3945220,"avatar_url":"https://avatars.githubusercontent.com/u/3945220?v=3","gravatar_id":"","url":"https://api.github.com/users/jh0ker","html_url":"https://github.com/jh0ker","followers_url":"https://api.github.com/users/jh0ker/followers","following_url":"https://api.github.com/users/jh0ker/following{/other_user}","gists_url":"https://api.github.com/users/jh0ker/gists{/gist_id}","starred_url":"https://api.github.com/users/jh0ker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jh0ker/subscriptions","organizations_url":"https://api.github.com/users/jh0ker/orgs","repos_url":"https://api.github.com/users/jh0ker/repos","events_url":"https://api.github.com/users/jh0ker/events{/privacy}","received_events_url":"https://api.github.com/users/jh0ker/received_events","type":"User","site_admin":false},"body":"A solution for #385 \r\n\r\nNot exactly what was requested, but very close and more versatile. Any handler can now request the `user_data` parameter, which is a `dict`. You can use it to store any data that is related to the user who sent the update. When the user sends another update, it will be the same `dict` with the same contents, across all handlers.\r\n\r\nA `chat_data` following the same concept has been added as well. ","created_at":"2016-10-10T14:53:54Z","updated_at":"2016-10-25T17:24:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"921f4923e2ba9ec8d389e47e9c26949199bfe064","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/436/commits","review_comments_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/436/comments","review_comment_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/issues/436/comments","statuses_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/statuses/99826a6276f9d8308852252a83f1ecf201c82473","head":{"label":"python-telegram-bot:user-storage","ref":"user-storage","sha":"99826a6276f9d8308852252a83f1ecf201c82473","user":{"login":"python-telegram-bot","id":16178365,"avatar_url":"https://avatars.githubusercontent.com/u/16178365?v=3","gravatar_id":"","url":"https://api.github.com/users/python-telegram-bot","html_url":"https://github.com/python-telegram-bot","followers_url":"https://api.github.com/users/python-telegram-bot/followers","following_url":"https://api.github.com/users/python-telegram-bot/following{/other_user}","gists_url":"https://api.github.com/users/python-telegram-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/python-telegram-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python-telegram-bot/subscriptions","organizations_url":"https://api.github.com/users/python-telegram-bot/orgs","repos_url":"https://api.github.com/users/python-telegram-bot/repos","events_url":"https://api.github.com/users/python-telegram-bot/events{/privacy}","received_events_url":"https://api.github.com/users/python-telegram-bot/received_events","type":"Organization","site_admin":false},"repo":{"id":38696925,"name":"python-telegram-bot","full_name":"python-telegram-bot/python-telegram-bot","owner":{"login":"python-telegram-bot","id":16178365,"avatar_url":"https://avatars.githubusercontent.com/u/16178365?v=3","gravatar_id":"","url":"https://api.github.com/users/python-telegram-bot","html_url":"https://github.com/python-telegram-bot","followers_url":"https://api.github.com/users/python-telegram-bot/followers","following_url":"https://api.github.com/users/python-telegram-bot/following{/other_user}","gists_url":"https://api.github.com/users/python-telegram-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/python-telegram-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python-telegram-bot/subscriptions","organizations_url":"https://api.github.com/users/python-telegram-bot/orgs","repos_url":"https://api.github.com/users/python-telegram-bot/repos","events_url":"https://api.github.com/users/python-telegram-bot/events{/privacy}","received_events_url":"https://api.github.com/users/python-telegram-bot/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/python-telegram-bot/python-telegram-bot","description":"We have made you a wrapper you can't refuse","fork":false,"url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot","forks_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/forks","keys_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/teams","hooks_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/hooks","issue_events_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/issues/events{/number}","events_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/events","assignees_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/assignees{/user}","branches_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/branches{/branch}","tags_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/tags","blobs_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/git/refs{/sha}","trees_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/statuses/{sha}","languages_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/languages","stargazers_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/stargazers","contributors_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/contributors","subscribers_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/subscribers","subscription_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/subscription","commits_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/commits{/sha}","git_commits_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/git/commits{/sha}","comments_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/comments{/number}","issue_comment_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/issues/comments{/number}","contents_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/contents/{+path}","compare_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/merges","archive_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/downloads","issues_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/issues{/number}","pulls_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls{/number}","milestones_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/milestones{/number}","notifications_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/labels{/name}","releases_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/releases{/id}","deployments_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/deployments","created_at":"2015-07-07T15:30:39Z","updated_at":"2016-10-25T11:28:15Z","pushed_at":"2016-10-24T04:35:57Z","git_url":"git://github.com/python-telegram-bot/python-telegram-bot.git","ssh_url":"git@github.com:python-telegram-bot/python-telegram-bot.git","clone_url":"https://github.com/python-telegram-bot/python-telegram-bot.git","svn_url":"https://github.com/python-telegram-bot/python-telegram-bot","homepage":"https://python-telegram-bot.org","size":2838,"stargazers_count":1473,"watchers_count":1473,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":337,"mirror_url":null,"open_issues_count":26,"forks":337,"open_issues":26,"watchers":1473,"default_branch":"master"}},"base":{"label":"python-telegram-bot:master","ref":"master","sha":"a1495956aa77877799d19b934ea8f4ce7f49f120","user":{"login":"python-telegram-bot","id":16178365,"avatar_url":"https://avatars.githubusercontent.com/u/16178365?v=3","gravatar_id":"","url":"https://api.github.com/users/python-telegram-bot","html_url":"https://github.com/python-telegram-bot","followers_url":"https://api.github.com/users/python-telegram-bot/followers","following_url":"https://api.github.com/users/python-telegram-bot/following{/other_user}","gists_url":"https://api.github.com/users/python-telegram-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/python-telegram-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python-telegram-bot/subscriptions","organizations_url":"https://api.github.com/users/python-telegram-bot/orgs","repos_url":"https://api.github.com/users/python-telegram-bot/repos","events_url":"https://api.github.com/users/python-telegram-bot/events{/privacy}","received_events_url":"https://api.github.com/users/python-telegram-bot/received_events","type":"Organization","site_admin":false},"repo":{"id":38696925,"name":"python-telegram-bot","full_name":"python-telegram-bot/python-telegram-bot","owner":{"login":"python-telegram-bot","id":16178365,"avatar_url":"https://avatars.githubusercontent.com/u/16178365?v=3","gravatar_id":"","url":"https://api.github.com/users/python-telegram-bot","html_url":"https://github.com/python-telegram-bot","followers_url":"https://api.github.com/users/python-telegram-bot/followers","following_url":"https://api.github.com/users/python-telegram-bot/following{/other_user}","gists_url":"https://api.github.com/users/python-telegram-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/python-telegram-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python-telegram-bot/subscriptions","organizations_url":"https://api.github.com/users/python-telegram-bot/orgs","repos_url":"https://api.github.com/users/python-telegram-bot/repos","events_url":"https://api.github.com/users/python-telegram-bot/events{/privacy}","received_events_url":"https://api.github.com/users/python-telegram-bot/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/python-telegram-bot/python-telegram-bot","description":"We have made you a wrapper you can't refuse","fork":false,"url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot","forks_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/forks","keys_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/teams","hooks_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/hooks","issue_events_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/issues/events{/number}","events_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/events","assignees_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/assignees{/user}","branches_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/branches{/branch}","tags_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/tags","blobs_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/git/refs{/sha}","trees_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/statuses/{sha}","languages_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/languages","stargazers_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/stargazers","contributors_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/contributors","subscribers_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/subscribers","subscription_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/subscription","commits_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/commits{/sha}","git_commits_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/git/commits{/sha}","comments_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/comments{/number}","issue_comment_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/issues/comments{/number}","contents_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/contents/{+path}","compare_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/merges","archive_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/downloads","issues_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/issues{/number}","pulls_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls{/number}","milestones_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/milestones{/number}","notifications_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/labels{/name}","releases_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/releases{/id}","deployments_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/deployments","created_at":"2015-07-07T15:30:39Z","updated_at":"2016-10-25T11:28:15Z","pushed_at":"2016-10-24T04:35:57Z","git_url":"git://github.com/python-telegram-bot/python-telegram-bot.git","ssh_url":"git@github.com:python-telegram-bot/python-telegram-bot.git","clone_url":"https://github.com/python-telegram-bot/python-telegram-bot.git","svn_url":"https://github.com/python-telegram-bot/python-telegram-bot","homepage":"https://python-telegram-bot.org","size":2838,"stargazers_count":1473,"watchers_count":1473,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":337,"mirror_url":null,"open_issues_count":26,"forks":337,"open_issues":26,"watchers":1473,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/436"},"html":{"href":"https://github.com/python-telegram-bot/python-telegram-bot/pull/436"},"issue":{"href":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/issues/436"},"comments":{"href":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/issues/436/comments"},"review_comments":{"href":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/436/comments"},"review_comment":{"href":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/436/commits"},"statuses":{"href":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/statuses/99826a6276f9d8308852252a83f1ecf201c82473"}}}}
{"actor":{"display_login":"jh0ker"}}