Skip to content

Instantly share code, notes, and snippets.

@kfdm
Created January 12, 2012 02:26
Show Gist options
  • Save kfdm/1598181 to your computer and use it in GitHub Desktop.
Save kfdm/1598181 to your computer and use it in GitHub Desktop.
Sample GNTP notification for feature request
import socket
REGISTER = """GNTP/1.0 REGISTER NONE
Application-Name: Testing
Notifications-Count: 1
Notification-Enabled: True
Notification-Name: Testing
"""
NOTIFY = """GNTP/1.0 NOTIFY NONE
Application-Name: Testing
Notification-Name: Testing
Notification-Text: Click to launch Google
Notification-Title: Test Title
Notification-Callback-Target: http://google.com
"""
for message in [REGISTER, NOTIFY]:
message = message.replace("\n", "\r\n").encode('utf8', 'replace')
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('localhost', 23053))
print 'Sending', '-' * 20
print message
s.send(message)
print 'Received', '-' * 20
print s.recv(1024)
s.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment