{"action":"created","comment":{"url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/pulls/comments/77461020","id":77461020,"diff_hunk":"@@ -124,34 +164,57 @@ class TelegramHandler(EventHandler):\n     def __init__(self, bot, config):\n         self.bot = bot\n         self.tbot = None\n-        self.master = config.get('master', None)\n+        master = config.get('master', None)\n         self.pokemons = config.get('alert_catch', {})\n         self.whoami = \"TelegramHandler\"\n         self.config = config\n+        if master == None:\n+            self.master = None\n+            return\n+\n+        with self.bot.database as conn:\n+            # if master is not numeric, try to fetch it from the database\n+            if not re.match(r'^[0-9]+$', str(master)): # master is numeric\n+                self.bot.logger.info(\"Telegram master is not numeric: {}\".format(master))\n+                c = conn.cursor()\n+                # do we already have a user id?\n+                srchmaster = re.sub(r'^@', '', master)\n+                c.execute(\"SELECT uid from telegram_uids where username in ('{}', '@{}')\".format(srchmaster, srchmaster))\n+                results = c.fetchall()\n+                if len(results) > 0: # woohoo, we already saw a message from this master and therefore have a uid\n+                    self.bot.logger.info(\"Telegram master UID from datastore: {}\".format(results[0][0]))\n+                    self.master = results[0][0]\n+                else: # uid not known yet\n+                    self.bot.logger.info(\"Telegram master UID not in datastore yet\")","path":"pokemongo_bot/event_handlers/telegram_handler.py","position":41,"original_position":114,"commit_id":"cdff48c694890ce74a992267a30133620a0f764b","original_commit_id":"cdff48c694890ce74a992267a30133620a0f764b","user":{"login":"DBa2016","id":20729632,"avatar_url":"https://avatars.githubusercontent.com/u/20729632?v=3","gravatar_id":"","url":"https://api.github.com/users/DBa2016","html_url":"https://github.com/DBa2016","followers_url":"https://api.github.com/users/DBa2016/followers","following_url":"https://api.github.com/users/DBa2016/following{/other_user}","gists_url":"https://api.github.com/users/DBa2016/gists{/gist_id}","starred_url":"https://api.github.com/users/DBa2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DBa2016/subscriptions","organizations_url":"https://api.github.com/users/DBa2016/orgs","repos_url":"https://api.github.com/users/DBa2016/repos","events_url":"https://api.github.com/users/DBa2016/events{/privacy}","received_events_url":"https://api.github.com/users/DBa2016/received_events","type":"User","site_admin":false},"body":"If you are reading the logs, you will be interested in this info, I think, which makes it \"info\" level, but lastly... - I don't care.","created_at":"2016-09-04T23:58:41Z","updated_at":"2016-09-04T23:58:41Z","html_url":"https://github.com/PokemonGoF/PokemonGo-Bot/pull/5182#discussion_r77461020","pull_request_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/pulls/5182","_links":{"self":{"href":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/pulls/comments/77461020"},"html":{"href":"https://github.com/PokemonGoF/PokemonGo-Bot/pull/5182#discussion_r77461020"},"pull_request":{"href":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/pulls/5182"}}},"pull_request":{"url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/pulls/5182","id":83927905,"html_url":"https://github.com/PokemonGoF/PokemonGo-Bot/pull/5182","diff_url":"https://github.com/PokemonGoF/PokemonGo-Bot/pull/5182.diff","patch_url":"https://github.com/PokemonGoF/PokemonGo-Bot/pull/5182.patch","issue_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/issues/5182","number":5182,"state":"open","locked":false,"title":"Persist UIDs received from Telegram","user":{"login":"DBa2016","id":20729632,"avatar_url":"https://avatars.githubusercontent.com/u/20729632?v=3","gravatar_id":"","url":"https://api.github.com/users/DBa2016","html_url":"https://github.com/DBa2016","followers_url":"https://api.github.com/users/DBa2016/followers","following_url":"https://api.github.com/users/DBa2016/following{/other_user}","gists_url":"https://api.github.com/users/DBa2016/gists{/gist_id}","starred_url":"https://api.github.com/users/DBa2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DBa2016/subscriptions","organizations_url":"https://api.github.com/users/DBa2016/orgs","repos_url":"https://api.github.com/users/DBa2016/repos","events_url":"https://api.github.com/users/DBa2016/events{/privacy}","received_events_url":"https://api.github.com/users/DBa2016/received_events","type":"User","site_admin":false},"body":"## Short Description:\r\nIn order to allow the user to enter username as master in Tegram bot config, store the username/uid relation in datastore - this way, this information surives bot restart.","created_at":"2016-09-04T16:50:28Z","updated_at":"2016-09-04T23:58:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"070e1fd8035d104ad371960b2788761f6ae34928","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/pulls/5182/commits","review_comments_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/pulls/5182/comments","review_comment_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/issues/5182/comments","statuses_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/statuses/cdff48c694890ce74a992267a30133620a0f764b","head":{"label":"DBa2016:mydev","ref":"mydev","sha":"cdff48c694890ce74a992267a30133620a0f764b","user":{"login":"DBa2016","id":20729632,"avatar_url":"https://avatars.githubusercontent.com/u/20729632?v=3","gravatar_id":"","url":"https://api.github.com/users/DBa2016","html_url":"https://github.com/DBa2016","followers_url":"https://api.github.com/users/DBa2016/followers","following_url":"https://api.github.com/users/DBa2016/following{/other_user}","gists_url":"https://api.github.com/users/DBa2016/gists{/gist_id}","starred_url":"https://api.github.com/users/DBa2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DBa2016/subscriptions","organizations_url":"https://api.github.com/users/DBa2016/orgs","repos_url":"https://api.github.com/users/DBa2016/repos","events_url":"https://api.github.com/users/DBa2016/events{/privacy}","received_events_url":"https://api.github.com/users/DBa2016/received_events","type":"User","site_admin":false},"repo":{"id":66957741,"name":"PokemonGo-Bot","full_name":"DBa2016/PokemonGo-Bot","owner":{"login":"DBa2016","id":20729632,"avatar_url":"https://avatars.githubusercontent.com/u/20729632?v=3","gravatar_id":"","url":"https://api.github.com/users/DBa2016","html_url":"https://github.com/DBa2016","followers_url":"https://api.github.com/users/DBa2016/followers","following_url":"https://api.github.com/users/DBa2016/following{/other_user}","gists_url":"https://api.github.com/users/DBa2016/gists{/gist_id}","starred_url":"https://api.github.com/users/DBa2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DBa2016/subscriptions","organizations_url":"https://api.github.com/users/DBa2016/orgs","repos_url":"https://api.github.com/users/DBa2016/repos","events_url":"https://api.github.com/users/DBa2016/events{/privacy}","received_events_url":"https://api.github.com/users/DBa2016/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DBa2016/PokemonGo-Bot","description":"The Pokemon Go Bot, baking with community.","fork":true,"url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot","forks_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/forks","keys_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/teams","hooks_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/hooks","issue_events_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/issues/events{/number}","events_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/events","assignees_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/assignees{/user}","branches_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/branches{/branch}","tags_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/tags","blobs_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/git/refs{/sha}","trees_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/statuses/{sha}","languages_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/languages","stargazers_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/stargazers","contributors_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/contributors","subscribers_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/subscribers","subscription_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/subscription","commits_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/commits{/sha}","git_commits_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/git/commits{/sha}","comments_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/comments{/number}","issue_comment_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/issues/comments{/number}","contents_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/contents/{+path}","compare_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/merges","archive_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/downloads","issues_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/issues{/number}","pulls_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/pulls{/number}","milestones_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/milestones{/number}","notifications_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/labels{/name}","releases_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/releases{/id}","deployments_url":"https://api.github.com/repos/DBa2016/PokemonGo-Bot/deployments","created_at":"2016-08-30T16:20:51Z","updated_at":"2016-08-30T16:20:53Z","pushed_at":"2016-09-04T21:30:32Z","git_url":"git://github.com/DBa2016/PokemonGo-Bot.git","ssh_url":"git@github.com:DBa2016/PokemonGo-Bot.git","clone_url":"https://github.com/DBa2016/PokemonGo-Bot.git","svn_url":"https://github.com/DBa2016/PokemonGo-Bot","homepage":"http://maps.pikabot.org","size":10926,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"dev"}},"base":{"label":"PokemonGoF:dev","ref":"dev","sha":"ddc731d1b9952b8b93b92495a5a6d744907c27e7","user":{"login":"PokemonGoF","id":20551204,"avatar_url":"https://avatars.githubusercontent.com/u/20551204?v=3","gravatar_id":"","url":"https://api.github.com/users/PokemonGoF","html_url":"https://github.com/PokemonGoF","followers_url":"https://api.github.com/users/PokemonGoF/followers","following_url":"https://api.github.com/users/PokemonGoF/following{/other_user}","gists_url":"https://api.github.com/users/PokemonGoF/gists{/gist_id}","starred_url":"https://api.github.com/users/PokemonGoF/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PokemonGoF/subscriptions","organizations_url":"https://api.github.com/users/PokemonGoF/orgs","repos_url":"https://api.github.com/users/PokemonGoF/repos","events_url":"https://api.github.com/users/PokemonGoF/events{/privacy}","received_events_url":"https://api.github.com/users/PokemonGoF/received_events","type":"Organization","site_admin":false},"repo":{"id":63752974,"name":"PokemonGo-Bot","full_name":"PokemonGoF/PokemonGo-Bot","owner":{"login":"PokemonGoF","id":20551204,"avatar_url":"https://avatars.githubusercontent.com/u/20551204?v=3","gravatar_id":"","url":"https://api.github.com/users/PokemonGoF","html_url":"https://github.com/PokemonGoF","followers_url":"https://api.github.com/users/PokemonGoF/followers","following_url":"https://api.github.com/users/PokemonGoF/following{/other_user}","gists_url":"https://api.github.com/users/PokemonGoF/gists{/gist_id}","starred_url":"https://api.github.com/users/PokemonGoF/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PokemonGoF/subscriptions","organizations_url":"https://api.github.com/users/PokemonGoF/orgs","repos_url":"https://api.github.com/users/PokemonGoF/repos","events_url":"https://api.github.com/users/PokemonGoF/events{/privacy}","received_events_url":"https://api.github.com/users/PokemonGoF/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PokemonGoF/PokemonGo-Bot","description":"The Pokemon Go Bot, baking with community.","fork":false,"url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot","forks_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/forks","keys_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/teams","hooks_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/hooks","issue_events_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/issues/events{/number}","events_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/events","assignees_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/assignees{/user}","branches_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/branches{/branch}","tags_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/tags","blobs_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/git/refs{/sha}","trees_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/statuses/{sha}","languages_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/languages","stargazers_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/stargazers","contributors_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/contributors","subscribers_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/subscribers","subscription_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/subscription","commits_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/commits{/sha}","git_commits_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/git/commits{/sha}","comments_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/comments{/number}","issue_comment_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/issues/comments{/number}","contents_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/contents/{+path}","compare_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/merges","archive_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/downloads","issues_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/issues{/number}","pulls_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/pulls{/number}","milestones_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/milestones{/number}","notifications_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/labels{/name}","releases_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/releases{/id}","deployments_url":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/deployments","created_at":"2016-07-20T05:31:53Z","updated_at":"2016-09-04T22:53:05Z","pushed_at":"2016-09-04T22:52:21Z","git_url":"git://github.com/PokemonGoF/PokemonGo-Bot.git","ssh_url":"git@github.com:PokemonGoF/PokemonGo-Bot.git","clone_url":"https://github.com/PokemonGoF/PokemonGo-Bot.git","svn_url":"https://github.com/PokemonGoF/PokemonGo-Bot","homepage":"http://maps.pikabot.org","size":17096,"stargazers_count":3714,"watchers_count":3714,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":1745,"mirror_url":null,"open_issues_count":120,"forks":1745,"open_issues":120,"watchers":3714,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/pulls/5182"},"html":{"href":"https://github.com/PokemonGoF/PokemonGo-Bot/pull/5182"},"issue":{"href":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/issues/5182"},"comments":{"href":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/issues/5182/comments"},"review_comments":{"href":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/pulls/5182/comments"},"review_comment":{"href":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/pulls/5182/commits"},"statuses":{"href":"https://api.github.com/repos/PokemonGoF/PokemonGo-Bot/statuses/cdff48c694890ce74a992267a30133620a0f764b"}}}}
{"actor":{"display_login":"DBa2016"}}