finger ossa@nummo.strangled.net
I have also devised an open relay for thimbl. Anyone can now make a microblog post, using only telnet. You can explore it right now (where now is defined as 23-Oct-2010, 18:19) as I have the open relay set up on my server. Here's what you do:
telnet nummo.strangled.net 2993
You can type
rece
to see the last 10 tweets. You can add your own tweet using the "say" command. For example:
say hello from the internet
Type "rece" again, and you should see your post. When you've have enough, type
quit
For further proof that it's worked, type
finger ossa@nummo.strangled.net
and you should see your post.
The code behind it (VERY hacky):
#!/usr/bin/env tclsh# Run this open relay server using# retweet.tcl# Example usage from the 'client' perspective:# telnet localhost 2993# C: OK Retweet says hello# S: rece <-- obtain a list of recent posts# C: blah blah 1# C: ...# C: OK Done# C: say i don't care what i say <-- create a posting# S: OK Done# C: quit <-- quit the server# socketry taken from# http://www.tcl.tk/about/netserver.html#fconfigure 0 -buffering line -blocking 0#fconfigure 1 -buffering line -blocking 0proc out { text } {puts 1 $textflush 1}# out "OK Retweet says hello"proc in {} {gets 0 inpreturn $inp}proc handle_input {out inp} {if {[regexp {^say (.+)} $inp _ tweet]} {# write the tweet to a fileset f1 [open "tweets" "a"]puts $f1 $tweetclose $f1# save the tweet in .planset f1 [open ".plan" "w"]puts $f1 $tweetclose $f1puts $out "OK Done"#flush stdoutreturn}if {[regexp {^rece} $inp]} {set f1 [open "| tail tweets" "r"]puts $out [read $f1]close $f1puts $out "OK Done"#flush stdoutreturn}if {$inp == "help"} {puts $out "Commands: help quit rece say"puts $out "OK Done"#flush stdoutreturn}if {$inp == "quit"} {puts $out "OK Quitting"#flush stdoutclose $outreturn}puts $out "FAIL Didn't understand command"#flush stdout}# Echo_Server --#Open the server listening socket#and enter the Tcl event loop## Arguments:#portThe server's port numberproc Echo_Server {port} {set s [socket -server EchoAccept $port]vwait forever}# Echo_Accept --#Accept a connection from a new client.#This is called after a new socket connection#has been created by Tcl.## Arguments:#sockThe new socket connection to the client#addrThe client's IP address#portThe client's port numberproc EchoAccept {sock addr port} {global echo# Record the client's informationputs "Accept $sock from $addr port $port"set echo(addr,$sock) [list $addr $port]# Ensure that each "puts" by the server# results in a network transmissionfconfigure $sock -buffering lineputs $sock "OK Greetings from fritter"# Set up a callback for when the client sends datafileevent $sock readable [list Echo $sock]}# Echo --#This procedure is called when the server#can read data from the client## Arguments:#sockThe socket connection to the clientproc Echo {sock} {global echo# Check end of file or abnormal connection drop,# then echo data back to the client.if {[eof $sock] || [catch {gets $sock line}]} {close $sockputs "Close $echo(addr,$sock)"unset echo(addr,$sock)} else {handle_input $sock $line#puts $sock $line}}Echo_Server 2993To run it, do the following:cd ~echo first post >~/.planecho first post >~/tweetstclsh retweet.tcl
You may want to combine it with the nohup command so that it isn't killed.
The code is also avialabe for download .
2 comments:
Hey Mark! I'm thrilled that your engaging with the ideas behind Thimbl, and realize how simple things could be. Why nut just join us? Making a console UI for Thimbl would both be much more difficult that what you've done above! Since we're a little backlogged on the the Web UI, your console UI may just be the first one released ;) -- Dmytri Kleiner
Hmm, I mean why not just join us, and would not be much more difficult! ^DK
Post a Comment