Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev merge to master, PR #3146

Merged
merged 45 commits into from
Aug 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
85f7607
Adding plugin support (#2679)
elicwhite Aug 7, 2016
f114be6
Moving the base task to the project root (#2702)
elicwhite Aug 7, 2016
0b319bc
Adding a heartbeat to the analytics (#2709)
elicwhite Aug 7, 2016
1c369a4
Don't double track clients
elicwhite Aug 7, 2016
e16b5ea
Fix 'local variable 'bot' referenced before assignment'
elicwhite Aug 7, 2016
e93431c
Providing an error if tasks don't work for the given api (#2732)
elicwhite Aug 7, 2016
d5bb09f
Fix for utf8 encoding when catching lured pokemon (#2720)
dkim1000 Aug 7, 2016
420c1be
Fix For catchable not being displayed on the web (#2719)
AcorpBG Aug 7, 2016
77200af
Added encrypt.so compilation process to Dockerfile (#2695)
Aug 7, 2016
e927195
OS Detection for encrypt lib (#2768)
brantje Aug 7, 2016
4f7888b
Fix Typo in unexpected_response_retry (#2531)
peter-bonanni Aug 7, 2016
e8f804a
Revert "changing license from MIT to GPLv3"
douglascamata Aug 7, 2016
27cf678
Merge branch 'dev' of github.com:PokemonGoF/PokemonGo-Bot into dev
douglascamata Aug 7, 2016
4eb7b38
When the google analytics domain is blocked the bot crashed. (#2764)
brantje Aug 7, 2016
6960f35
Fixes #2698 - Prevents "Possibly searching too often" error after re-…
geek-man Aug 7, 2016
eeecbc6
Support loading plugins from .zip files (#2766)
elicwhite Aug 7, 2016
2750255
Keep track of how many pokemon released (#2884)
bixuanzju Aug 7, 2016
823ba83
Setting Library path to work with encrypt.so (#2899)
bernardoVale Aug 7, 2016
fc4e802
:sparkles: Added login and username to available stats (#2494)
Aug 7, 2016
e5b7eda
[dev] small fixes (#2912)
mjmadsen Aug 7, 2016
dee28d9
Rename load_path to load_plugin (#2947)
elicwhite Aug 7, 2016
0855dac
Adding some logic for pulling plugins from github (#2967)
elicwhite Aug 8, 2016
a1733b9
flush after title update (#2977)
mhdasding Aug 8, 2016
e66c509
correctly re-raise exception to keep backtrace (#2944)
rbignon Aug 8, 2016
bdcf251
Update MoveToMapPokemon to use events instead of logger. (#2913)
chrisle Aug 8, 2016
95902d6
Config/encrypt.so (#2964)
DevScarabyte Aug 8, 2016
41ed10c
Fixed mispelling for "formatted" variable (#2984)
middleagedman Aug 8, 2016
563f898
Loading plugins from Github (#2992)
elicwhite Aug 8, 2016
229381c
Fixed #3000 (#3003)
raulgbcr Aug 8, 2016
1a18b9f
Added MaxPotion inventory count to summary. (#3015)
JaapMoolenaar Aug 8, 2016
4faf962
Added cleanup of download and files for encrypt.so after they are no …
Aug 8, 2016
7cc524e
Fix bot not returning back after telepoting (#3014)
bixuanzju Aug 8, 2016
283c17e
Fix Dockerfile installation (#3057)
nikofil Aug 8, 2016
351ea76
Fix for #3045 (#3055)
cmezh Aug 8, 2016
20aeb90
Added request to check configuration (#3089)
mjmadsen Aug 8, 2016
ff380cd
Fixed Dockerfile - missing \ on command lines (#3096)
middleagedman Aug 8, 2016
a5e9131
Fix for FileIO slowing bot performance.This puts the map writing into…
ajurna Aug 8, 2016
d8546d7
Change word usage: "fled" to "escaped" (#3118)
DeviousFusion Aug 8, 2016
0b3aa4f
Update the example config file (#3120)
hklcf Aug 8, 2016
d0f60a2
typo: logrmation -> information (#2601)
gokaygurcan Aug 8, 2016
f648be3
Change fled to escaped (#3129)
pmquan Aug 8, 2016
47ab81f
When JSON parsing fails, give a rough indication of why (#3137)
cwild Aug 8, 2016
c8a33bc
Handle Github Download Zip Format (#3108)
elicwhite Aug 8, 2016
625275c
Merge branch 'master' into dev
solderzzc Aug 8, 2016
5fb1f04
Merge branch 'dev' of https://github.com/PokemonGoF/PokemonGo-Bot int…
solderzzc Aug 8, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Please check configuration at http://jsonlint.com/ before posting an issue.

### Expected Behavior


Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ var/
.pydevproject
.settings/

# Cloud9 Users
.c9/

# Installer logs
pip-log.txt
pip-delete-this-directory.txt
Expand Down Expand Up @@ -86,6 +89,8 @@ celerybeat-schedule
# virtualenv
venv/
ENV/
local/
share/

# Spyder project settings
.spyderproject
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@
* lucasfevi
* Moonlight-Angel
* mjmadsen
* nikofil
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ RUN cd /tmp && wget "http://pgoapi.com/pgoencrypt.tar.gz" \
&& tar zxvf pgoencrypt.tar.gz \
&& cd pgoencrypt/src \
&& make \
&& cp libencrypt.so /usr/src/app/encrypt.so
&& cp libencrypt.so /usr/src/app/encrypt.so \
&& cd /tmp \
&& rm -rf /tmp/pgoencrypt*

VOLUME ["/usr/src/app/web"]

Expand Down
1 change: 1 addition & 0 deletions configs/config.json.cluster.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"password": "YOUR_PASSWORD",
"location": "SOME_LOCATION",
"gmapkey": "GOOGLE_MAPS_API_KEY",
"libencrypt_location": "",
"tasks": [
{
"type": "HandleSoftBan"
Expand Down
1 change: 1 addition & 0 deletions configs/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"password": "YOUR_PASSWORD",
"location": "SOME_LOCATION",
"gmapkey": "GOOGLE_MAPS_API_KEY",
"libencrypt_location": "",
"tasks": [
{
"type": "HandleSoftBan"
Expand Down
1 change: 1 addition & 0 deletions configs/config.json.map.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"password": "YOUR_PASSWORD",
"location": "SOME_LOCATION",
"gmapkey": "GOOGLE_MAPS_API_KEY",
"libencrypt_location": "",
"tasks": [
{
"type": "HandleSoftBan"
Expand Down
1 change: 1 addition & 0 deletions configs/config.json.path.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"password": "YOUR_PASSWORD",
"location": "SOME_LOCATION",
"gmapkey": "GOOGLE_MAPS_API_KEY",
"libencrypt_location": "",
"tasks": [
{
"type": "HandleSoftBan"
Expand Down
1 change: 1 addition & 0 deletions configs/config.json.pokemon.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"password": "YOUR_PASSWORD",
"location": "SOME_LOCATION",
"gmapkey": "GOOGLE_MAPS_API_KEY",
"libencrypt_location": "",
"tasks": [
{
"type": "HandleSoftBan"
Expand Down
File renamed without changes.
35 changes: 27 additions & 8 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
from pokemongo_bot.health_record import BotEvent
from pokemongo_bot.plugin_loader import PluginLoader

try:
from demjson import jsonlint
except ImportError:
# Run `pip install -r requirements.txt` to fix this
jsonlint = None

if sys.version_info >= (2, 7, 9):
ssl._create_default_https_context = ssl._create_unverified_context

Expand All @@ -53,7 +59,7 @@

def main():
bot = False

try:
logger.info('PokemonGO Bot v1.0')
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
Expand Down Expand Up @@ -104,7 +110,7 @@ def main():
'api_error',
sender=bot,
level='info',
formmated='Log logged in, reconnecting in {:s}'.format(wait_time)
formatted='Log logged in, reconnecting in {:d}'.format(wait_time)
)
time.sleep(wait_time)
except ServerBusyOrOfflineException:
Expand All @@ -130,7 +136,7 @@ def main():
if bot:
report_summary(bot)

raise e
raise

def report_summary(bot):
if bot.metrics.start_time is None:
Expand Down Expand Up @@ -162,16 +168,28 @@ def init_config():
# If config file exists, load variables from json
load = {}

def _json_loader(filename):
try:
with open(filename, 'rb') as data:
load.update(json.load(data))
except ValueError:
if jsonlint:
with open(filename, 'rb') as data:
lint = jsonlint()
rc = lint.main(['-v', filename])

logger.critical('Error with configuration file')
sys.exit(-1)

# Select a config file code
parser.add_argument("-cf", "--config", help="Config File to use")
config_arg = parser.parse_known_args() and parser.parse_known_args()[0].config or None

if config_arg and os.path.isfile(config_arg):
with open(config_arg) as data:
load.update(json.load(data))
_json_loader(config_arg)
elif os.path.isfile(config_file):
logger.info('No config argument specified, checking for /configs/config.json')
with open(config_file) as data:
load.update(json.load(data))
_json_loader(config_file)
else:
logger.info('Error: No /configs/config.json or specified config')

Expand Down Expand Up @@ -384,6 +402,7 @@ def init_config():
if not config.password and 'password' not in load:
config.password = getpass("Password: ")

config.encrypt_location = load.get('encrypt_location','')
config.catch = load.get('catch', {})
config.release = load.get('release', {})
config.action_wait_max = load.get('action_wait_max', 4)
Expand Down Expand Up @@ -446,7 +465,7 @@ def task_configuration_error(flag_name):

plugin_loader = PluginLoader()
for plugin in config.plugins:
plugin_loader.load_path(plugin)
plugin_loader.load_plugin(plugin)

# create web dir if not exists
try:
Expand Down
65 changes: 56 additions & 9 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import re
import sys
import time
import Queue
import threading

from geopy.geocoders import GoogleV3
from pgoapi import PGoApi
Expand Down Expand Up @@ -69,6 +71,11 @@ def __init__(self, config):
# Make our own copy of the workers for this instance
self.workers = []

# Theading setup for file writing
self.web_update_queue = Queue.Queue(maxsize=1)
self.web_update_thread = threading.Thread(target=self.update_web_location_worker)
self.web_update_thread.start()

def start(self):
self._setup_event_system()
self._setup_logging()
Expand Down Expand Up @@ -249,7 +256,7 @@ def _register_events(self):
)
)
self.event_manager.register_event(
'pokemon_fled',
'pokemon_escaped',
parameters=('pokemon',)
)
self.event_manager.register_event(
Expand Down Expand Up @@ -393,6 +400,35 @@ def _register_events(self):
)
self.event_manager.register_event('unset_pokemon_nickname')

# Move To map pokemon
self.event_manager.register_event(
'move_to_map_pokemon_fail',
parameters=('message',)
)
self.event_manager.register_event(
'move_to_map_pokemon_updated_map',
parameters=('lat', 'lon')
)
self.event_manager.register_event(
'move_to_map_pokemon_teleport_to',
parameters=('poke_name', 'poke_dist', 'poke_lat', 'poke_lon',
'disappears_in')
)
self.event_manager.register_event(
'move_to_map_pokemon_encounter',
parameters=('poke_name', 'poke_dist', 'poke_lat', 'poke_lon',
'disappears_in')
)
self.event_manager.register_event(
'move_to_map_pokemon_move_towards',
parameters=('poke_name', 'poke_dist', 'poke_lat', 'poke_lon',
'disappears_in')
)
self.event_manager.register_event(
'move_to_map_pokemon_teleport_back',
parameters=('last_lat', 'last_lon')
)

def tick(self):
self.health_record.heartbeat()
self.cell = self.get_meta_cell()
Expand Down Expand Up @@ -607,7 +643,6 @@ def login(self):
)

def get_encryption_lib(self):
file_name = ''
if _platform == "linux" or _platform == "linux2" or _platform == "darwin":
file_name = 'encrypt.so'
elif _platform == "Windows" or _platform == "win32":
Expand All @@ -617,15 +652,18 @@ def get_encryption_lib(self):
else:
file_name = 'encrypt.dll'

path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
full_path = path + '/'+ file_name
if self.config.encrypt_location == '':
path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
else:
path = self.config.encrypt_location

full_path = path + '/'+ file_name
if not os.path.isfile(full_path):
self.logger.error(file_name + ' is not found! Please place it in the bots root directory.')
self.logger.info('Platform: '+ _platform + ' Bot root directory: '+ path)
self.logger.error(file_name + ' is not found! Please place it in the bots root directory or set libencrypt_location in config.')
self.logger.info('Platform: '+ _platform + ' Encrypt.so directory: '+ path)
sys.exit(1)
else:
self.logger.info('Found '+ file_name +'! Platform: ' + _platform + ' Bot root directory: ' + path)
self.logger.info('Found '+ file_name +'! Platform: ' + _platform + ' Encrypt.so directory: ' + path)

return full_path

Expand Down Expand Up @@ -716,7 +754,8 @@ def _print_character_info(self):
self.logger.info(
'Potion: ' + str(items_stock[101]) +
' | SuperPotion: ' + str(items_stock[102]) +
' | HyperPotion: ' + str(items_stock[103]))
' | HyperPotion: ' + str(items_stock[103]) +
' | MaxPotion: ' + str(items_stock[104]))

self.logger.info(
'Incense: ' + str(items_stock[401]) +
Expand Down Expand Up @@ -944,7 +983,15 @@ def heartbeat(self):
request.get_player()
request.check_awarded_badges()
request.call()
self.update_web_location() # updates every tick
try:
self.web_update_queue.put_nowait(True) # do this outside of thread every tick
except Queue.Full:
pass

def update_web_location_worker(self):
while True:
self.web_update_queue.get()
self.update_web_location()

def get_inventory_count(self, what):
response_dict = self.get_inventory()
Expand Down
Loading