This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

make bot answer on an external telnet session

Old posts that have not been replied to for several years.
Locked
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

make bot answer on an external telnet session

Post by Ofloo »

i want to do this telnet into a shell, and on a event (text) that passes by i would like to put a command to that window like ... telnet into a shell or machine what ever and the session prompts for something to answer how could i make the bot answer this question ?

what command would i use ?
XplaiN but think of me as stupid
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

ok how do i use this ? with binds and stuff there seems nothing on it in the help pages
13. TCP connections

Eggdrop allows you to make two types of TCP ("telnet") connections: outgoing and incoming. For an outgoing connection, you specify the remote host and port to connect to. For an incoming connection, you specify a port to listen on.

All of the connections are *event driven*. This means that the bot will trigger your procs when something happens on the connection, and your proc is expected to return as soon as possible. Waiting in a proc for more input is a no-no.

To initiate an outgoing connection, use:

set idx [connect <hostname> <port>]

$idx now contains a new DCC entry for the outgoing connection.

All connections use non-blocking (commonly called "asynchronous", which is a misnomer) I/O. Without going into a big song and dance about asynchronous I/O, what this means to you is:

assume the connection succeeded immediately

if the connection failed, an EOF will arrive for that idx

The only time a 'connect' will return an error is if you give it a hostname that can't be resolved (this is considered a "DNS error"). Otherwise, it will appear to have succeeded. If the connection failed, you will immediately get an EOF.

Right after doing a 'connect' call, you should set up a 'control' for the new idx (see the section above). From then on, the connection will act just like a normal DCC connection that has been put under the control of a script. If you ever return "1" from the control proc (indicating that you want control to return to Eggdrop), the bot will just close the connection and dispose of it. Other commands that work on normal DCC connections, like 'killdcc' and 'putdcc', will work on this idx, too. The 'killdcc' command will fail with "invalid idx" if you attempt to use it on a closed socket.

To create a listen port, use:

listen <port> script <proc>

Procs should be declared as:

procname <newidx>

For example:

listen 6687 script listen:grab

proc listen:grab {newidx} {
control $newidx listen:control
}

When a new connection arrives in port 6687, Eggdrop will create a new idx for the connection. That idx is sent to 'listen:grab'. The proc immediately puts this idx under control. Once 'listen:grab' has been called, the idx behaves exactly like an outgoing connection would.

The best way to learn how to use these commands is to find a script that uses them and follow it carefully. However, hopefully this has given you a good start.

14. Match characters

Many of the bindings allow match characters in the arguments. Here are the four special characters:

?
matches any single character

*
matches 0 or more characters of any type

%
matches 0 or more non-space characters (can be used to match a single word)

~
matches 1 or more space characters (can be used for whitespace between words)
XplaiN but think of me as stupid
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

why not use the socket command instead? I like it alot better, but that's my opinion ;)
Just use fileevent readable/writeable to catch/put lines/commands
Elen sila lúmenn' omentielvo
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

could i read contents of telnet from an exe with socket ? nice ill give it a try tnx for the suggestion ;) ima get back to you on that once ive read on it hehe so i can ask more questions in case i have any ;)
XplaiN but think of me as stupid
C
Carnage69
Halfop
Posts: 64
Joined: Sat Jun 07, 2003 8:25 pm

really

Post by Carnage69 »

i really dont telnet to my bot that mutch i know should more couse i have a roughter and i cant dcc chat so all i can do it make public commands it is dumb but o well...
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

i think you didn't read what i asked or didn't understand :) its not about that kind of telnet session
XplaiN but think of me as stupid
C
Carnage69
Halfop
Posts: 64
Joined: Sat Jun 07, 2003 8:25 pm

i really dident read

Post by Carnage69 »

i dident read it all i saw was telnet and i come running ;-)
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

LOL np hehe just wanted to help out hehe
XplaiN but think of me as stupid
C
Carnage69
Halfop
Posts: 64
Joined: Sat Jun 07, 2003 8:25 pm

help

Post by Carnage69 »

what does this op crap mean i was a voice now i am a op??
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

It's automatically set based on the number of posts you have
1-49 = voice
50-99 = op
99-499 = master
>500 = revered one
Elen sila lúmenn' omentielvo
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

just test with this part ;) but there is something wrong ..

Code: Select all

bind PUB n !test test:pub

proc test:pub {nick uhost hand chan arg} {
  set execute [socket localhost 5068]
  foreach line [split [read $execute] \n] {
    if {"$line" == "*Copyright*"} {
      puts $execute "test.bat"
    }
  }
}
it won't read it and if it doesn't read or send .. am i doing something wrong cause ive read socket like 20 times but can't see what it is i am missing ..
XplaiN but think of me as stupid
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

Code: Select all

bind PUB n !test test:pub 

proc test:pub {nick uhost hand chan arg} { 
  set execute [socket localhost 5068]
  fileveevnt $execute writeable [list newproc $execute]
}

proc newproc {x} {
  fconfigure $x -blocking 0 -buffering line
  if {![eof $x]} {
    gets $x line
    if {"$line" == "*Copyright*"} { 
      puts $execute "test.bat" 
    }
  } else {
    filevent $x writeable {}
  }
}
this should give you some ideas
Elen sila lúmenn' omentielvo
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

hmm well its not doing anything i do understand what you wrote and i must admit its nice didn't even know you could call a proc in an other proc and like you used args .. (x) didn't know that either so if i understand write $x = $execute but .. for instance this doesn't work either

also isn't this supposed to be while ?
if {![eof $x]} {
didn't change it while tho just not sur why its if
proc test:pub {nick uhost hand chan arg} {
set execute [socket localhost 5068]
puts $execute "test.bat"
}
and it should cause i open up a cat window to receive connections so i can see what its doing and if it would put test.bat as it should it would show on the session and it doesn't .. so is there an other way of putting stuff into the channel ... ? am i doing some thin wrong..
XplaiN but think of me as stupid
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

I just gave you that code to push you in the right direction, I never said it would work ;)
but... yes, it's supposed to be if {![eof $x]} { cause the proc is called once everytime the fileid becomes writeable...
if you connect to an external telenet from your bot, it will have to login. You need to add some checks in the second proc to see if it asks for login-name ....etc

also, add this line right below the first fileevent:

Code: Select all

fileveevnt $execute readable [list newproc $execute] 
also, if you intend to keep the connection open until you tell it to shutdown, you can add a vwait and make it wait forever (waiting for a varaible that'snever set)
Elen sila lúmenn' omentielvo
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

oh ok sorry and tnx verry mutch ;)
oh no its a non login telnet session its like a cat window ;) to test it you know, its a telnet session that opens up and closes down on disconnecting from it i just run it every time i disconnect so i can see what the bot is doing :)

ima read up on it on what you sad vwait when i don't understand something ill let you know if you don't mind ;)
XplaiN but think of me as stupid
Locked