-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Map-Chat / Crowd Sourced Data #4596
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c700097
Update main.js
BreezeRo 861dcda
Update map.js
BreezeRo 9a68450
Create social_handler.py
BreezeRo 57b0027
Update __init__.py
BreezeRo 610bcea
Update pokecli.py
BreezeRo 04ef948
Update requirements.txt
BreezeRo a309e74
Update __init__.py
BreezeRo f06c8ed
Update config.json.example
BreezeRo a93fbd9
Update config.json.cluster.example
BreezeRo 8049aa3
Update config.json.map.example
BreezeRo d82d1ce
Update config.json.optimizer.example
BreezeRo 2c4bc06
Update config.json.path.example
BreezeRo 820ea82
Update config.json.pokemon.example
BreezeRo e786f5d
To make CI happy.
solderzzc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from logging_handler import LoggingHandler | ||
from socketio_handler import SocketIoHandler | ||
from colored_logging_handler import ColoredLoggingHandler | ||
from social_handler import SocialHandler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# -*- coding: utf-8 -*- | ||
from pokemongo_bot.event_manager import EventHandler | ||
import thread | ||
import paho.mqtt.client as mqtt | ||
class MyMQTTClass: | ||
def __init__(self, clientid=None): | ||
self._mqttc = mqtt.Client(clientid) | ||
self._mqttc.on_message = self.mqtt_on_message | ||
#self._mqttc.on_connect = self.mqtt_on_connect | ||
#self._mqttc.on_publish = self.mqtt_on_publish | ||
#self._mqttc.on_subscribe = self.mqtt_on_subscribe | ||
#def mqtt_on_connect(self, mqttc, obj, flags, rc): | ||
#print "rc: "+str(rc) | ||
def mqtt_on_message(self, mqttc, obj, msg): | ||
print msg.topic+" "+str(msg.qos)+" "+str(msg.payload) | ||
#def mqtt_on_publish(self, mqttc, obj, mid): | ||
#print "mid: "+str(mid) | ||
#def mqtt_on_subscribe(self, mqttc, obj, mid, granted_qos): | ||
# print "Subscribed: "+str(mid)+" "+str(granted_qos) | ||
#def mqtt_on_log(self, mqttc, obj, level, string): | ||
# print string | ||
def publish(self, channel, message): | ||
self._mqttc.publish(channel, message) | ||
def connect_to_mqtt(self): | ||
self._mqttc.connect("test.mosca.io", 1883, 60) | ||
self._mqttc.subscribe("pgomapcatch/#", 0) | ||
def run(self): | ||
self._mqttc.loop_forever() | ||
class SocialHandler(EventHandler): | ||
def __init__(self, bot): | ||
self.bot = bot | ||
self.mqttc = MyMQTTClass() | ||
self.mqttc.connect_to_mqtt() | ||
thread.start_new_thread(self.mqttc.run) | ||
def handle_event(self, event, sender, level, formatted_msg, data): | ||
#sender_name = type(sender).__name__ | ||
#if formatted_msg: | ||
# message = "[{}] {}".format(event, formatted_msg) | ||
#else: | ||
#message = '{}: {}'.format(event, str(data)) | ||
if event == 'catchable_pokemon': | ||
#self.mqttc.publish("pgomapcatch/all", str(data)) | ||
#print data | ||
if data['pokemon_id']: | ||
#self.mqttc.publish("pgomapcatch/all/catchable/"+str(data['pokemon_id']), str(data)) | ||
self.mqttc.publish("pgomapcatch/all/catchable/"+str(data['pokemon_id']), str(data['latitude'])+","+str(data['longitude'])+","+str(data['encounter_id'])) | ||
|
||
#print 'have catchable_pokemon' | ||
#print message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,4 @@ raven==5.23.0 | |
demjson==2.2.4 | ||
greenlet==0.4.9 | ||
yoyo-migrations==5.0.3 | ||
paho-mqtt==1.2 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BreezeRo Could you change line 1063 and 1070 back? This was merged in PR #4581.