Created
November 6, 2009 08:39
-
-
Save dzfl/227849 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
# vim:fileencoding=utf-8 | |
require 'socket' | |
require 'digest/sha1' | |
def send(msg) | |
print msg + "\r\n" | |
sock = TCPSocket.open('192.168.1.12', '23053') | |
sock.write msg | |
while f = sock.gets | |
break if f == "\r\n" | |
print f | |
end | |
print "\r\n" | |
end | |
pass = "secret" | |
salt = "saltsalt" | |
dig = Digest::MD5.hexdigest(Digest::MD5.digest(pass + salt)) | |
#GNTP/1.0 NOTIFY NONE MD5:CAED6C49CB987A67BA249A0F12E72317.43696A3153322F2F | |
#GNTP/1.0 NOTIFY NONE MD5:#{dig}.#{salt} | |
msg1 = <<EOF | |
GNTP/1.0 REGISTER NONE MD5:#{dig}.#{salt.unpack("H*").join} | |
Application-Name: Yet Another Github G | |
Application-Icon: | |
Notifications-Count: 1 | |
Notification-Name: foo | |
Notification-Display-Name: foo | |
Notification-Enabled: True | |
Notification-Sticky: False | |
Notification-Priority: 0 | |
Notification-Icon: | |
EOF | |
# Notification-Iconが404とかだと300エラーが出るけど一応通る。 | |
msg2 = <<EOF | |
GNTP/1.0 NOTIFY NONE MD5:#{dig}.#{salt.unpack("H*").join.upcase} | |
Application-Name: Yet Another Github G | |
Notification-Name: foo | |
Notification-ID: IDDD | |
Notification-Priority: 1 | |
Notification-Title: my notify | |
Notification-Text: my message | |
Notification-Sticky: true | |
Notification-Icon: http://groups.google.com/group/growl-development/icon?hl=ja | |
EOF | |
msg1.gsub!(/\n/, "\r\n") | |
msg2.gsub!(/\n/, "\r\n") | |
#send(msg1) | |
send(msg2) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment