Joined: 22 Feb 2004 Posts: 121 Location: Richmond, VA
Posted: Tue Dec 07, 2004 9:44 am Post subject:
Sonora::Interface::Telnet v0.2
This is the first release of my Telnet interface for Sonora. Basically it creates a listening server on the port you specify and accepts incoming connections from a telnet client. This is a very initial release so it does not work perfectly, but the basic functionality is there. It has been tested with Windows telnet command and Putty and works fairly well with both.
This interface has 2 wonderful uses. First, you can use this just as another interface for your users to connect to. Even if a user doesn't have a IM client installed, they can still contact the bot threw telnet, because most Operating Systems come with a telnet command. Secondly, it's a great way for you to test your bot w/o having to connect to an IM server. It takes milliseconds for the bot to start up with just this interface and you can test your bot with no latency.
Have fun with it and let me know what I need to fix.
In the included zip is a test script called telnettest.pl and the module Telnet.pm that you should put in your .../Sonora/Interfaces/ folder.
Updated to v0.2. I made username pretty, added a friendly name (the users ip) and fixed a few bugs.
Joined: 15 Mar 2004 Posts: 661 Location: Manchester, UK
Posted: Tue Dec 07, 2004 5:05 pm Post subject:
It sounds very cool and everything but we need the download. _________________ MSN: gavin [at] gavinbrittain [dot] co [dot] uk
E-Portfolio: www.gavinbrittain.co.uk (New version comming soon)
That's really cool! I might implement telnet into my bot... I don't know if it would get any users to that interface, but I've been thinking of telnet things for a while (though not for a bot; I was planning to make a password-protected telnet server for doin' DOS commands on my machine from elsewhere ) _________________ Current Site (2008) http://www.cuvou.com/
Joined: 22 Feb 2004 Posts: 121 Location: Richmond, VA
Posted: Tue Dec 07, 2004 11:07 pm Post subject:
QUOTE(Cer @ Dec 7 2004, 12:41 PM)
That's really cool! I might implement telnet into my bot... I don't know if it would get any users to that interface, but I've been thinking of telnet things for a while (though not for a bot; I was planning to make a password-protected telnet server for doin' DOS commands on my machine from elsewhere )
Well the biggest reason I made it is for testing of my own bots. I can just add this interface and test my bot w/o even having to be connected to the internet.
Yeah, I've done HTTP interfaces to bots.... the problem is that HTTP::Daemon doesn't work well with loops (daemon = idle process that sits in the background and waits until it's provoked), so it doesn't run well with looping bots.
You could probably use a really basic server object, that DOES do looping, and program it yourself though (the HTTP commands are very simple... a request from a client is like "GET /index.html" - and then you return some stuff back). _________________ Current Site (2008) http://www.cuvou.com/
Joined: 19 Jul 2004 Posts: 556 Location: Los Angeles, CA votes: 1
Posted: Wed Dec 08, 2004 12:48 am Post subject:
accually you can use the http damon in looping bots i made onw a while ago also...you can make the waiting conncetion time out just like ithe sockets do in the msn.pm
I think i acculayy released it in a white warrier template
my $d = new HTTP::Daemon (LocalPort => 180, Timeout=>.1);
then: $d->accept; will time out and work well with loops _________________ [ matt ]
Joined: 19 Jul 2004 Posts: 556 Location: Los Angeles, CA votes: 1
Posted: Wed Dec 08, 2004 1:21 am Post subject:
because it will hang at #<<<-----BIG LOOP tell there is a request, and with the timeout you are onlytimeing out the accetp request not opening and closeing the port. Did you test what you posetd... you would see your BIG LOOP is blocking. So if you wrote the rest of your program in that loop it would hang until there was each http request (probly not good for most programs)
Code:
#!/usr/bin/perl<br /> use HTTP::Daemon;<br />use HTTP::Status;<br /><br />my $d = new HTTP::Daemon (LocalPort => 180, Timeout=>.1);<br /> print "Please contact me at: <URL:", $d->url, ">\n";<br /><br />while(1){<br />print "in loop\n"; <br />http_loop();<br />}<br /><br />sub http_loop{<br /> my $c = $d->accept || return;<br /> while (my $*lazy* = $c->get_request) {<br /> my $rs = new HTTP::Response(RC_OK);<br /> $rs->content( '<html><h1>test 2</h1></html>');<br /> $c->send_response($rs);<br /> }<br /> $c->close;<br /> undef($c);<br />}