Skip to content

Instantly share code, notes, and snippets.

@brianpeiris
Last active December 13, 2015 16:39
Show Gist options
  • Save brianpeiris/4942152 to your computer and use it in GitHub Desktop.
Save brianpeiris/4942152 to your computer and use it in GitHub Desktop.
A bit of Python code for listening to events from a PubNub channel and triggering a mouse wheel scroll event.
from Pubnub import Pubnub
from datetime import datetime
from guippy import mouse
subkey = '<your subcribe key>'
pubkey = '<your publish key>'
channel = '<your channel name>'
pubnub = Pubnub(pubkey, subkey, None, False)
def receive(message) :
print('%s message received: %s' % (datetime.now(), message))
mouse._mouse_event(2048, 0, 0, -120 * 10)
return True
print('Listening for events from Twine...');
pubnub.subscribe({
'channel' : channel,
'callback' : receive
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment