-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Map-Chat / Crowd Sourced Data (#4596)
* Update main.js * Update map.js * Create social_handler.py * Update __init__.py * Update pokecli.py * Update requirements.txt * Update __init__.py * Update config.json.example * Update config.json.cluster.example * Update config.json.map.example * Update config.json.optimizer.example * Update config.json.path.example * Update config.json.pokemon.example * To make CI happy.
- Loading branch information
Showing
13 changed files
with
200 additions
and
50 deletions.
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 |