Created
March 31, 2009 13:52
-
-
Save snaka/88200 to your computer and use it in GitHub Desktop.
GNTP test program for ruby
This file contains hidden or 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/ruby | |
# GNTP test program for ruby | |
# | |
require 'socket' | |
def send_and_recieve msg | |
msg.gsub!(/\n/, "\r\n") | |
print msg | |
sock = TCPSocket.open('localhost', 23053) | |
sock.write msg | |
while rcv = sock.gets | |
break if rcv == "\r\n" | |
print ">#{rcv}" | |
end | |
sock.close | |
end | |
# REGISTER | |
send_and_recieve <<EOF | |
GNTP/1.0 REGISTER NONE | |
Application-Name: Ruby sample | |
Notifications-Count: 1 | |
Notification-Name: GrowlTest | |
Notification-Display-Name: GrowlTest | |
Notification-Enabled: True | |
Notification-Icon: http://www.hatena.ne.jp/users/sn/snaka72/profile.gif | |
EOF | |
# NOTIFY | |
send_and_recieve <<EOF | |
GNTP/1.0 NOTIFY NONE | |
Application-Name: Ruby sample | |
Notification-Name: GrowlTest | |
Notification-Title: こんにちはグロウル | |
Notification-Text: Growlが来た! | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment