egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Announce Bot w/ Telnet

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
TehSky
Voice


Joined: 27 May 2009
Posts: 4

PostPosted: Wed May 27, 2009 2:05 am    Post subject: Announce Bot w/ Telnet Reply with quote

I'm trying to have create an announcebot that gets information through a telnet connection. Using this script.

Code:
set Port "51010"
set Chan "#channel"

listen $Port script listenb

proc listenb {idx} {
control $idx listenb1
}

proc listenb1 {idx args} {

set args [join $args]
set Announce [join [lrange [split $args] 0 end]]

putquick "PRIVMSG $::Chan :$Announce"
}

putlog "Announce Loaded"


My problem is I get this in the DCC chat with my Eggdrop.

Quote:
Telnet connection: mywebsite.com/43942
Timeout/EOF ident connection


I tried .+host *!*@* and it didnt work, any ideas?
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed May 27, 2009 3:49 am    Post subject: Reply with quote

Your web-server doesn't run an identd service, and thus your eggdrop will make a note of that.

To avoid this, you could try using tcl server sockets instead. Using this socket interface is a little more cumbersome though. I believe something like this should do the trick:
Code:
set servsock [socket -server handleConnect 51010]

proc handleConnect {socket clientIP clientPort} {
  fconfigure $socket -blocking 0
  fileevent $socket readable [readSocket $socket]
}

proc readSocket {socket} {
  while {[gets $socket line] >= 0} {
    puthelp "PRIVMSG $::Chan :$line"
  }
  if {[eof $socket]} {
    close $socket
  }
}


Finally, a hint for future coding, stay away from the variable name "args", and you won't have to do all this string<->list juggling you are doing. Eggdrop bindings always call the associated command with a fixed number of arguments for each kind of binding, so you don't need to accept arbitrary number of arguments.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Wed May 27, 2009 9:24 am    Post subject: Reply with quote

I have posted a similar thread not too long ago, similarly discussing the EOF/Timeout party line event with nml375.

http://forum.egghelp.org/viewtopic.php?t=16877

It does seem likely that the event is caused by failure to respond to an identd request made by the destination bot. I can tell you that the event occurs irrespective of whether you use connect/control or native Tcl sockets (assuming there is no identd daemon to respond). At worst, it simply causes a finite but small delay in connecting.

You can see a screenshot of my script in if you look at the URL I just pasted, it seems to be functioning well. If you are interested, pm me and I will give you an address where you can download it.
_________________
I must have had nothing to do
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed May 27, 2009 9:27 am    Post subject: Reply with quote

arfer, the big difference here, is that we are dealing with server sockets versus listen, not client sockets vs connect. Your case is rather different, as you are required to use listen as you wish the connection to gain access to the dcc partyline, which this case does not require. Hence, the use of server sockets should get rid of those log notices...
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Wed May 27, 2009 9:37 am    Post subject: Reply with quote

Thanks, I wasn't picking that up from the original post.

I did end up using native Tcl sockets. The whole connect/control mechanism seemed sort of 'unfinished' and the documentation erroneous.
_________________
I must have had nothing to do
Back to top
View user's profile Send private message
TehSky
Voice


Joined: 27 May 2009
Posts: 4

PostPosted: Wed May 27, 2009 1:09 pm    Post subject: Reply with quote

Thank you very much for your help everyone. Unfortunately I am still getting an EOF error with nml375's script. But more was added.

Quote:
Telnet connection: unknown.mywebsite.com/37874
Timeout/EOF ident connection
Lost telnet connection to telnet@unknown.mywebsite.com/37874


This is what I have on the webserver sending the information.

Code:
#
$ANS = fsockopen('64.85.160.159', 51010);
#
fputs($ANS, $Announce);
#
sleep(8);
#
fclose($ANS);

Long Version: http://txt.srinsr.in/index.php/view/34356603
Back to top
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Wed May 27, 2009 2:16 pm    Post subject: Reply with quote

i have some script which i wrote for someone on another forum, this script is sending simple msgs to the eggdrop, you can fix it for yourself:

here is 'eggsend.php' (file name should be the same like in <form> action and in header()):
Code:
<?php
//eggdrop host port
        $egg_port = 1234;
//eggdrop host ip
        $egg_ip = '10.0.1.10';

        if (isset($_POST['message'])) {
                $msg = $_POST['message'];

                $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
                socket_connect($sock, $egg_ip, $egg_port) or die ('can\'t connect!');
                socket_write($sock, $msg);
                socket_close($sock);
                header("Location: ./eggsend.php");
        }

        echo "<form action='eggsend.php' method='POST'>";
                echo "<input type='text' name='message' cols='20'><br>";
                echo "<input type='submit' value='send'>";
        echo "</form>";
?>
~


here is script for eggdrop:
Code:
set output_chan "#channel"

# eggdrop port to bind
set port 1234
# eggdrop ip to bind
set host 10.0.1.10

set serverSocket [socket -server main -myaddr $host $port]

proc main { sock host port } {
        fconfigure $sock -buffering line
        fileevent $sock readable [action $sock $host $port]
}

proc action { chan host port } {
        global output_chan

        if {![eof $chan]} {
                set soc_data [gets $chan]

                if {$soc_data != ""} {
                        putquick "PRIVMSG $output_chan :$host | $port | $soc_data"
                }
        } {
                close $chan
        }
}

putlog "sock-server.tcl"


i sent: "lala" through page

bot on chan:
Quote:
19:54:54 < botty> lala


about your problem, maybe bot is getting timeout cause your php script is holding connection to long?

in those scripts, you are sending information just once, i mean : connect -> send one line -> disconnect, there is no holding of connection

don't know how many data your php script is sending at one time, maybe fix it or something and make it like this "send" script, connect -> announce -> disconnect, and after another connect -> announce -> disconnect

/edit/

just try to load my tcl script to your eggdrop, set up proper ip and port and after change in your php script:

Code:
$ANS = fsockopen('64.85.160.159', 51010);
fputs($ANS, $Announce);
sleep(8);
fclose($ANS);


to:
Code:
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_connect($sock, '64.85.160.159', 51010) or die ('can\'t connect!');
socket_write($sock, $msg);
socket_close($sock);


and check it, use this php script in proper way Smile
bot should write announce to the chan,
for tests, you can try to use short message: socket_write($sock, "test me");
Back to top
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed May 27, 2009 5:29 pm    Post subject: Reply with quote

Did you remember to do a complete restart of your eggdrop, in order to remove the old code? A simple .rehash would not suffice in this case.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
TehSky
Voice


Joined: 27 May 2009
Posts: 4

PostPosted: Wed May 27, 2009 7:42 pm    Post subject: Reply with quote

Quote:
[18:39] couldn't open socket: address already in use
while executing
"socket -server main -myaddr $host $port"
invoked from within
"set serverSocket [socket -server main -myaddr $host $port]"
(file "scripts/announce.tcl" line Cool
invoked from within
"source scripts/announce.tcl"
(file "eggdrop.conf" line 1337)
[18:39] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)


From the SSH when trying to load eggdrop with your script. Announce .tcl = The Script. @tomekk

nml375 wrote:
Did you remember to do a complete restart of your eggdrop, in order to remove the old code? A simple .rehash would not suffice in this case.


Yes I did. But after using tomekk's changes to the php, I got a Lost Connection while resolving hostname.
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Thu May 28, 2009 9:29 am    Post subject: Reply with quote

Then you did either not fully restart your eggdrop, or you are loading several of these scripts at once. If you do see that ident/EOF error, that means you've still got that "listen ¤Port script listenb" line lying around somewhere.

"Couldn't open socket: address already in use" means just that, there is already some process listening on that ip:port. As such, you cannot create a new server socket with that very same address. This again suggests you did not remove that old "listen-based" script.

Considering the orientation of your php-script, I'm not sure how much further help can be given at this forum.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
TehSky
Voice


Joined: 27 May 2009
Posts: 4

PostPosted: Thu May 28, 2009 1:48 pm    Post subject: Reply with quote

Yep, figures. Anyways, there is no listenb sitting anywhere and there is only one script.

Thanks for the help you gave I guess.
Back to top
View user's profile Send private message
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Thu May 28, 2009 7:45 pm    Post subject: Reply with quote

Change the port.
_________________
Have you ever read "The Manual"?
Back to top
View user's profile Send private message
putyn
Voice


Joined: 07 Feb 2011
Posts: 2

PostPosted: Mon Feb 07, 2011 6:44 pm    Post subject: Reply with quote

hey i know that this is an old topic but i really hope someone could help me
what i want to do is similar to this send data from php to the eggdrop but after that i need eggdrop to send some data back back to the php script

any idea would be appreciated
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Tue Feb 08, 2011 7:01 am    Post subject: Reply with quote

user had posted some interesting stuff in "socket api - nonblocking tcp made easy", worth reading. You should open your own topic and refer to this topic to give it as an example.
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber