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.

socket bot help..

Help for those learning Tcl or writing their own scripts.
Post Reply
s
sdays
Halfop
Posts: 98
Joined: Sat Oct 21, 2006 4:46 am

socket bot help..

Post by sdays »

Can some one help me with this socket bot..

i get:

Code: Select all

<eggdrop> [02:46] Tcl error [socket:add]: missing close-bracket

Code: Select all

bind pub - !addbot socket:add

proc socket:add {nick uhost hand chan} {
  global nick realname username socket:chan socket:serv socket:nick socket:conn
  set socketnick $nick[rand 1000]
  set chan "$text0"
  set serv "text1"
  set port "text2"
  if {![validchan $chan]} {
    putserv "NOTICE $nick :Invalid Channel"
    putserv "NOTICE $nick :usage: !addbot <channel> <server> \[port\]"
    } else {
    if {$serv == ""} {
      putserv "NOTICE $nick :Specify a Server"
      putserv "NOTICE $nick :usage: !addbot <channel> <server> \[port\]"
      } else {
      if {[info exists $socket:conn]} {
        if {[valididx $socket:conn} {
          putserv "NOTICE $nick :QUIT :Switching Servers"
          killdcc $socket:conn
        }
      }
      if {$port == ""} {
        set socket:conn [connect $serv 6667]
        } else {
        if {$port != ""} {set socket:conn [connect $serv $port]}
      }
      set socket:chan $chan
      set socket:serv $serv
      putlc "USER $username 0 0 :$realname"
      putlc "NICK :$socket:nick"
    }
    return 1
  }
}
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

If you indented your code properly, you'd be able to find the missing close bracket.
s
sdays
Halfop
Posts: 98
Joined: Sat Oct 21, 2006 4:46 am

Post by sdays »

Im not really good a tcl scripting..
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

sdays wrote:Im not really good a tcl scripting..
For every open brace '{' there has to be a matching closing one '}'.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
s
sdays
Halfop
Posts: 98
Joined: Sat Oct 21, 2006 4:46 am

Post by sdays »

Ok i fix that part but now it, now won't connect to irc..

Code: Select all

bind pub - !addbot socket:add

proc socket:add {nick uhost hand chan arg} {
  global realname username socket:chan socket:serv socket:conn
  set nick [lindex $arg 0]
  set chan [lindex $arg 1]
  set serv [lindex $arg 2]
  set port [lindex $arg 3]
  if {![validchan $chan]} {
    putserv "NOTICE $nick :Invalid Channel"
    putserv "NOTICE $nick :usage: !addbot <nick> <channel> <server> \[port\]"
    } else {
    if {$serv == ""} {
      putserv "NOTICE $nick :Specify a Server"
      putserv "NOTICE $nick :usage: !addbot <nick> <channel> <server> \[port\]"
    }
  }
  if {$port == ""} {
    set socket:conn [connect $serv 6667]
    } else {
    if {$port != ""} {set socket:conn [connect $serv $port]}
  }
  set socket:chan $chan
  set socket:serv $serv
  puts "USER $username 0 0 :$realname"
  puts "NICK :$nick"
}
return 1
}
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Post the results of:

Code: Select all

.set errorInfo
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
s
sdays
Halfop
Posts: 98
Joined: Sat Oct 21, 2006 4:46 am

Post by sdays »

i get this <eggdrop> Currently: wrong # args: should be "error message ?errorInfo? ?errorCode?"
s
sdays
Halfop
Posts: 98
Joined: Sat Oct 21, 2006 4:46 am

Post by sdays »

Btw im wanting this tcl so it check for invite spam every 10 mins or so..
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

sdays wrote:Btw im wanting this tcl so it check for invite spam every 10 mins or so..
http://www.demond.net/spambuster.tcl
Have you ever read "The Manual"?
s
sdays
Halfop
Posts: 98
Joined: Sat Oct 21, 2006 4:46 am

Post by sdays »

hmm thats not what im looking for im wanting it on a socket bot
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

sdays wrote:hmm thats not what im looking for im wanting it on a socket bot
Then why are you using 'connect'? demond's script does what you claim to be trying to do.
http://www.demond.net/spambuster.tcl wrote:# this will fork a clone to scan for spam on bot's own channels
...using 'connect' to make the tcp connection
Have you ever read "The Manual"?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Might be worth mentioning, that you currently mix tcl's I/O mechanisms with eggdrop's own socket-implementations. They are not compatible; ie. you cannot use 'puts' with sockets opened with 'connect' or 'listen'. In the same fashion, you cannot use 'putidx' or 'control' with sockets created with the 'socket' command.

Each method has it own advantages and disadvantages; so I'd suggest you read up on both and decide on which to use before you proceed with coding this script.

Also, on a sidenote, I can't stress enough how bad it is to use list-commands (such as 'lindex') on strings. Please use 'split' to convert strings into lists when neccesary.
NML_375
Post Reply