Skip to content

Commit

Permalink
Merge pull request #6206 from MerlionRock/Killswitch
Browse files Browse the repository at this point in the history
Killswitch
  • Loading branch information
nbq authored Aug 19, 2017
2 parents 022e6cc + d56fc80 commit f8921bd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions configs/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"websocket_server": false,
"heartbeat_threshold": 10,
"enable_social": false,
"killswitch": true,
"check_niantic_api": false,
"solve_captcha": false,
"bypass_warning": false,
Expand Down
5 changes: 5 additions & 0 deletions killswitch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"killswitch": true,
"activated_by": "MerlionRock",
"message": "Current API is unsafe.\nPlease visit our Discord Channel (Announcement) for more information.\nTo overwrite killswitch, add \"killswitch\": \"false\" to config.json"
}
21 changes: 21 additions & 0 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import argparse
import codecs
import json
import urllib2
import logging
import os
import six
Expand Down Expand Up @@ -101,13 +102,24 @@ def yes_no(question):

def initialize(config):
from pokemongo_bot.datastore import Datastore
killswitch_url = 'https://raw.githubusercontent.com/PokemonGoF/PokemonGo-Bot/dev/killswitch.json'

# Allow user to by pass warning without question
if config.bypass_warning:
bypass_warning = config.bypass_warning
else:
bypass_warning = False

if config.killswitch:
response = urllib2.urlopen(killswitch_url)
killswitch_data = json.load(response)
response.close()

if killswitch_data['killswitch']:
print "\033[91mKill Switch Activated By: \033[0m" + format(killswitch_data['activated_by'])
print "\033[91mMessage: \033[0m\n" + format(killswitch_data['message']) + "\n\n\n"
sys.exit(1)

try:
import pkg_resources
pgoapi_version = pkg_resources.get_distribution("pgoapi").version
Expand Down Expand Up @@ -461,6 +473,15 @@ def _json_loader(filename):
type=bool,
default=False
)
add_config(
parser,
load,
short_flag="-ksw",
long_flag="--killswitch",
help="Do you want to enable killswitch",
type=bool,
default=True
)
add_config(
parser,
load,
Expand Down

0 comments on commit f8921bd

Please sign in to comment.