{"action":"created","comment":{"url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/pulls/comments/72903541","id":72903541,"diff_hunk":"@@ -0,0 +1,134 @@\n+# -*- coding: utf-8 -*-\n+\n+from __future__ import print_function\n+import random\n+import time\n+\n+from pokemongo_bot.human_behaviour import sleep\n+from pokemongo_bot.event_manager import manager\n+from pokemongo_bot import logger\n+\n+\n+@manager.on(\"pokemon_found\")\n+def pokemon_found(bot, encounters=None):\n+    # type: (PokemonGoBot, Optional[List[Encounter]]) -> None\n+\n+    if encounters is None or len(encounters) == 0:\n+        return\n+\n+    def log(text, color=\"black\"):\n+        logger.log(text, color=color, prefix=\"Catch\")\n+\n+    for pokemon_encounter in encounters:\n+        encounter_id = pokemon_encounter['encounter_id']\n+        spawn_point_id = pokemon_encounter['spawn_point_id']\n+        player_latitude = pokemon_encounter['latitude']\n+        player_longitude = pokemon_encounter['longitude']\n+        bot.api_wrapper.encounter(encounter_id=encounter_id,\n+                                  spawn_point_id=spawn_point_id,\n+                                  player_latitude=player_latitude,\n+                                  player_longitude=player_longitude)\n+\n+        response = bot.api_wrapper.call()\n+\n+        encounter_data = response[\"encounter\"]\n+        status = encounter_data.status\n+        if status is 7:\n+            # Pokemon bag is full, fire event and return for now\n+            log(\"Pokemon bag is full; cannot catch.\", color=\"red\")\n+            bot.fire(\"pokemon_bag_full\")\n+            return\n+        elif status is 1:\n+            pokemon = encounter_data.wild_pokemon\n+\n+            if pokemon is None:\n+                return\n+\n+            combat_power = pokemon.combat_power\n+            total_iv = pokemon.attack + pokemon.defense + pokemon.stamina","path":"plugins/catch_pokemon/__init__.py","position":48,"original_position":48,"commit_id":"52a30908d79bc2a8f984b64c53fb81ae5ca29877","original_commit_id":"52a30908d79bc2a8f984b64c53fb81ae5ca29877","user":{"login":"andythorne","id":1301181,"avatar_url":"https://avatars.githubusercontent.com/u/1301181?v=3","gravatar_id":"","url":"https://api.github.com/users/andythorne","html_url":"https://github.com/andythorne","followers_url":"https://api.github.com/users/andythorne/followers","following_url":"https://api.github.com/users/andythorne/following{/other_user}","gists_url":"https://api.github.com/users/andythorne/gists{/gist_id}","starred_url":"https://api.github.com/users/andythorne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andythorne/subscriptions","organizations_url":"https://api.github.com/users/andythorne/orgs","repos_url":"https://api.github.com/users/andythorne/repos","events_url":"https://api.github.com/users/andythorne/events{/privacy}","received_events_url":"https://api.github.com/users/andythorne/received_events","type":"User","site_admin":false},"body":"I added a `pokemon.potential` attribute in https://github.com/OpenPoGo/OpenPoGoBot/pull/115 so we don't have to keep doing this :)","created_at":"2016-07-31T12:35:08Z","updated_at":"2016-07-31T12:35:08Z","html_url":"https://github.com/OpenPoGo/OpenPoGoBot/pull/129#discussion_r72903541","pull_request_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/pulls/129","_links":{"self":{"href":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/pulls/comments/72903541"},"html":{"href":"https://github.com/OpenPoGo/OpenPoGoBot/pull/129#discussion_r72903541"},"pull_request":{"href":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/pulls/129"}}},"pull_request":{"url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/pulls/129","id":79479204,"html_url":"https://github.com/OpenPoGo/OpenPoGoBot/pull/129","diff_url":"https://github.com/OpenPoGo/OpenPoGoBot/pull/129.diff","patch_url":"https://github.com/OpenPoGo/OpenPoGoBot/pull/129.patch","issue_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/issues/129","number":129,"state":"open","locked":false,"title":"Cell worker refactor","user":{"login":"wchill","id":3746651,"avatar_url":"https://avatars.githubusercontent.com/u/3746651?v=3","gravatar_id":"","url":"https://api.github.com/users/wchill","html_url":"https://github.com/wchill","followers_url":"https://api.github.com/users/wchill/followers","following_url":"https://api.github.com/users/wchill/following{/other_user}","gists_url":"https://api.github.com/users/wchill/gists{/gist_id}","starred_url":"https://api.github.com/users/wchill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wchill/subscriptions","organizations_url":"https://api.github.com/users/wchill/orgs","repos_url":"https://api.github.com/users/wchill/repos","events_url":"https://api.github.com/users/wchill/events{/privacy}","received_events_url":"https://api.github.com/users/wchill/received_events","type":"User","site_admin":false},"body":"### Short Description: \r\nRemoves most of the `cell_workers` and turn them into plugins that can be enabled/disabled, like in #126. This cleans up `__init__.py` considerably, since for catching Pokemon, transferring Pokemon, discarding items, and spinning PokeStops, the bot does not have to do anything except fire events.\r\n\r\nSome other miscellaneous changes/fixes were made.\r\n\r\nNote that `walk_towards_fort_worker` still needs a refactor; since it also handles bot movement, this was not refactored. The best way to refactor this should be discussed in #127.\r\n\r\n### Changes:\r\n- `pokemon_catch_worker`, `initial_transfer_worker`, `recycle_items_worker` and `seen_fort_worker` refactored into plugins.\r\n- `logger` plugin was removed since logging statements should be handled by each plugin separately.\r\n- Bot now outputs a list of loaded plugins and available events for easier debugging/developing.\r\n- Fixed bug with inventory not being counted properly.\r\n- Fixed a bug with the `web` plugin where it would cause stack overflow due to a circular event loop.\r\n- Fix wrong key being used for `cooldown_complete_timestamp_ms` for PokeStops.\r\n- On API error, wrapper now waits 10 seconds for every error state.\r\n- Miscellaneous changes to logging output.\r\n\r\n@OpenPoGo/maintainers\r\n\r\n","created_at":"2016-07-31T08:08:56Z","updated_at":"2016-07-31T12:35:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"df38caf70a211294ae3d854f3bbb46344456b983","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/pulls/129/commits","review_comments_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/pulls/129/comments","review_comment_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/issues/129/comments","statuses_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/statuses/52a30908d79bc2a8f984b64c53fb81ae5ca29877","head":{"label":"OpenPoGo:feature/more-events","ref":"feature/more-events","sha":"52a30908d79bc2a8f984b64c53fb81ae5ca29877","user":{"login":"OpenPoGo","id":20617614,"avatar_url":"https://avatars.githubusercontent.com/u/20617614?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenPoGo","html_url":"https://github.com/OpenPoGo","followers_url":"https://api.github.com/users/OpenPoGo/followers","following_url":"https://api.github.com/users/OpenPoGo/following{/other_user}","gists_url":"https://api.github.com/users/OpenPoGo/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenPoGo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenPoGo/subscriptions","organizations_url":"https://api.github.com/users/OpenPoGo/orgs","repos_url":"https://api.github.com/users/OpenPoGo/repos","events_url":"https://api.github.com/users/OpenPoGo/events{/privacy}","received_events_url":"https://api.github.com/users/OpenPoGo/received_events","type":"Organization","site_admin":false},"repo":{"id":64036807,"name":"OpenPoGoBot","full_name":"OpenPoGo/OpenPoGoBot","owner":{"login":"OpenPoGo","id":20617614,"avatar_url":"https://avatars.githubusercontent.com/u/20617614?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenPoGo","html_url":"https://github.com/OpenPoGo","followers_url":"https://api.github.com/users/OpenPoGo/followers","following_url":"https://api.github.com/users/OpenPoGo/following{/other_user}","gists_url":"https://api.github.com/users/OpenPoGo/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenPoGo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenPoGo/subscriptions","organizations_url":"https://api.github.com/users/OpenPoGo/orgs","repos_url":"https://api.github.com/users/OpenPoGo/repos","events_url":"https://api.github.com/users/OpenPoGo/events{/privacy}","received_events_url":"https://api.github.com/users/OpenPoGo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OpenPoGo/OpenPoGoBot","description":"A PokemonGo Python bot","fork":false,"url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot","forks_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/forks","keys_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/teams","hooks_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/hooks","issue_events_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/issues/events{/number}","events_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/events","assignees_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/assignees{/user}","branches_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/branches{/branch}","tags_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/tags","blobs_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/git/refs{/sha}","trees_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/statuses/{sha}","languages_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/languages","stargazers_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/stargazers","contributors_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/contributors","subscribers_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/subscribers","subscription_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/subscription","commits_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/commits{/sha}","git_commits_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/git/commits{/sha}","comments_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/comments{/number}","issue_comment_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/issues/comments{/number}","contents_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/contents/{+path}","compare_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/merges","archive_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/downloads","issues_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/issues{/number}","pulls_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/pulls{/number}","milestones_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/milestones{/number}","notifications_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/labels{/name}","releases_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/releases{/id}","deployments_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/deployments","created_at":"2016-07-23T21:28:35Z","updated_at":"2016-07-31T10:47:31Z","pushed_at":"2016-07-31T09:54:41Z","git_url":"git://github.com/OpenPoGo/OpenPoGoBot.git","ssh_url":"git@github.com:OpenPoGo/OpenPoGoBot.git","clone_url":"https://github.com/OpenPoGo/OpenPoGoBot.git","svn_url":"https://github.com/OpenPoGo/OpenPoGoBot","homepage":"","size":5024,"stargazers_count":57,"watchers_count":57,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":34,"mirror_url":null,"open_issues_count":19,"forks":34,"open_issues":19,"watchers":57,"default_branch":"master"}},"base":{"label":"OpenPoGo:master","ref":"master","sha":"ec5b155d6d10047a5d06a9394012fc3017d5787f","user":{"login":"OpenPoGo","id":20617614,"avatar_url":"https://avatars.githubusercontent.com/u/20617614?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenPoGo","html_url":"https://github.com/OpenPoGo","followers_url":"https://api.github.com/users/OpenPoGo/followers","following_url":"https://api.github.com/users/OpenPoGo/following{/other_user}","gists_url":"https://api.github.com/users/OpenPoGo/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenPoGo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenPoGo/subscriptions","organizations_url":"https://api.github.com/users/OpenPoGo/orgs","repos_url":"https://api.github.com/users/OpenPoGo/repos","events_url":"https://api.github.com/users/OpenPoGo/events{/privacy}","received_events_url":"https://api.github.com/users/OpenPoGo/received_events","type":"Organization","site_admin":false},"repo":{"id":64036807,"name":"OpenPoGoBot","full_name":"OpenPoGo/OpenPoGoBot","owner":{"login":"OpenPoGo","id":20617614,"avatar_url":"https://avatars.githubusercontent.com/u/20617614?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenPoGo","html_url":"https://github.com/OpenPoGo","followers_url":"https://api.github.com/users/OpenPoGo/followers","following_url":"https://api.github.com/users/OpenPoGo/following{/other_user}","gists_url":"https://api.github.com/users/OpenPoGo/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenPoGo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenPoGo/subscriptions","organizations_url":"https://api.github.com/users/OpenPoGo/orgs","repos_url":"https://api.github.com/users/OpenPoGo/repos","events_url":"https://api.github.com/users/OpenPoGo/events{/privacy}","received_events_url":"https://api.github.com/users/OpenPoGo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OpenPoGo/OpenPoGoBot","description":"A PokemonGo Python bot","fork":false,"url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot","forks_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/forks","keys_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/teams","hooks_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/hooks","issue_events_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/issues/events{/number}","events_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/events","assignees_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/assignees{/user}","branches_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/branches{/branch}","tags_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/tags","blobs_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/git/refs{/sha}","trees_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/statuses/{sha}","languages_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/languages","stargazers_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/stargazers","contributors_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/contributors","subscribers_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/subscribers","subscription_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/subscription","commits_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/commits{/sha}","git_commits_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/git/commits{/sha}","comments_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/comments{/number}","issue_comment_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/issues/comments{/number}","contents_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/contents/{+path}","compare_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/merges","archive_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/downloads","issues_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/issues{/number}","pulls_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/pulls{/number}","milestones_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/milestones{/number}","notifications_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/labels{/name}","releases_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/releases{/id}","deployments_url":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/deployments","created_at":"2016-07-23T21:28:35Z","updated_at":"2016-07-31T10:47:31Z","pushed_at":"2016-07-31T09:54:41Z","git_url":"git://github.com/OpenPoGo/OpenPoGoBot.git","ssh_url":"git@github.com:OpenPoGo/OpenPoGoBot.git","clone_url":"https://github.com/OpenPoGo/OpenPoGoBot.git","svn_url":"https://github.com/OpenPoGo/OpenPoGoBot","homepage":"","size":5024,"stargazers_count":57,"watchers_count":57,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":34,"mirror_url":null,"open_issues_count":19,"forks":34,"open_issues":19,"watchers":57,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/pulls/129"},"html":{"href":"https://github.com/OpenPoGo/OpenPoGoBot/pull/129"},"issue":{"href":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/issues/129"},"comments":{"href":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/issues/129/comments"},"review_comments":{"href":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/pulls/129/comments"},"review_comment":{"href":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/pulls/129/commits"},"statuses":{"href":"https://api.github.com/repos/OpenPoGo/OpenPoGoBot/statuses/52a30908d79bc2a8f984b64c53fb81ae5ca29877"}}}}
{"actor":{"display_login":"andythorne"}}