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.

Need help with my tcl.

Old posts that have not been replied to for several years.
Locked
G
Gothic-Angel
Op
Posts: 109
Joined: Mon Sep 23, 2002 9:46 pm

Need help with my tcl.

Post by Gothic-Angel »

www.justintime.darktech.org/DALnetServices.tcl


I want to have it support multiple channels, and send the op request to only the channel that he is needed to op in.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Hi, for multiple channels support add something like:

Code: Select all

setudef flag something
...
foreach $ch [chanlist] {
if {[lsearch -exact [channel info $chan] -something] != -1} { continue }
rest of the code..
}
And change from 'something' flag to whatever suits you better. For it's *need's* use something like this:

Code: Select all

setudef flag csneed

bind need - * cs:need

proc cs:need {channel type} { 
  global botnick
  if {[lsearch -exact [channel info $channel] -csneed] != -1} { return 0 }
  switch -- $type {
    "op" {
      putserv "PRIVMSG Chanserv :op $channel $botnick"
    return 1 }
    "unban" {
      putserv "PRIVMSG Chanserv :unban $channel $botnick"
    return 1 }
    "invite" {
      putserv "PRIVMSG Chanserv :invite $channel $botnick"
    return 1 }
    "limit" {
      putserv "PRIVMSG Chanserv :invite $channel $botnick"
    return 1 }
  }
}
Also, for it's *unban* thing:

Code: Select all

bind mode - "* +b" my:chban

proc cs:chban {nick uhost hand chan mc ban} {
  global botname
  set bmask "*!*@[lindex [split $uhost @] 1]" 
  if {[string match "$ban" "$botname"] && [botisop $chan]} {
    if {[string match "$bmask" "$botname"]} { set bmask [maskhost *!*[string trimleft $uhost ~]]}
      if {$nick == "X" } {
      putserv "PRIVMSG Chanserv :unban $chan $bmask"
      return } else {
      putquick "MODE $chan -bo+b $ban $nick $bmask"
    putquick "KICK $chan $nick :\002\00312Don't ban me you twit!" }
    return
  }
}
Replace the user defined channel flags to what you want. Hope I've helped you or something.. :)
Once the game is over, the king and the pawn go back in the same box.
G
Gothic-Angel
Op
Posts: 109
Joined: Mon Sep 23, 2002 9:46 pm

Post by Gothic-Angel »

so to use this in my script I would have to add a special flag for a channel? like .chanset #blah +service ?
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Exactly. ;]
Once the game is over, the king and the pawn go back in the same box.
G
Gothic-Angel
Op
Posts: 109
Joined: Mon Sep 23, 2002 9:46 pm

Post by Gothic-Angel »

Im still lost on how to implement the code, im rather new and just trying to figure things out.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

The majoc line in thsi script is "setudef flag csneed".

"setudef" the command, which tells the bot to create new channel based setting.

"flag" is the type, which can be flag (+ or - type setting like +bitch), int (which can hold a number, eg "20"), or str/string (can't remember which, new for 1.6.14 when it comes out. can hold text).

"csneed" is the name fo the setting.

In this case, a flag called csneed.

This can be changed using

.chanset #channel +csneed

The next line of code, that is is needed, is

Code: Select all

if {[lsearch -exact [channel info $channel] -csneed] != -1} { return 0 }
This should be added in the positions mentioned.

You can now change the channel + or -csneed now.

You may wish to change the csneed, to somthing you like. However, once you have chosen the name, stick to it, else you have to change the channel settings again.
G
Gothic-Angel
Op
Posts: 109
Joined: Mon Sep 23, 2002 9:46 pm

Post by Gothic-Angel »

I should have been more specific I got that part down, I just didnt have the

Code: Select all

setudef flag something 
... 
foreach $ch [chanlist] { 
if {[lsearch -exact [channel info $chan] -something] != -1} { continue } 
rest of the code.. 
} 
part down I got an error at the $ch part,
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

You don't need that code in your script.

It was an example of the code that can be used to do it.

The rest is what you need.
G
Gothic-Angel
Op
Posts: 109
Joined: Mon Sep 23, 2002 9:46 pm

Post by Gothic-Angel »

I see, thanks for all the help everyone. Ill fully test it out when I have time.
G
Gothic-Angel
Op
Posts: 109
Joined: Mon Sep 23, 2002 9:46 pm

Post by Gothic-Angel »

Code: Select all

set channame "#blah"
set nickserv "nickserv@services.dal.net"
set chanserv "chanserv@services.dal.net"
set memoserv "memoserv@services.dal.net"
set blah "."
set pass "pass.txt"
set nicknametxt "nick.txt"
set fs [open $nicknametxt r]
set nickname [read $fs 32]

bind notc - "*This nick is owned by someone else*" services_ident
bind notc - "*Password accepted*" services_check
bind notc - "*You do not have access to op people*" services_ident
bind time - "5 * *" services_check
bind time - "10 * *" services_check
bind time - "15 * *" services_check
bind time - "20 * *" services_check
bind time - "25 * *" services_check
bind time - "30 * *" services_check
bind time - "35 * *" services_check
bind time - "40 * *" services_check
bind time - "45 * *" services_check
bind time - "50 * *" services_check
bind time - "55 * *" services_check
bind time - "00 * *" services_check
bind pub n|n ${blah}identify pub:ident
bind pub n|n ${blah}op pub:op
bind pub n|n ${blah}test services_check
bind ctcr - PING services_op
bind mode - "* -o" services_autoreop
bind dcc - mem services_memo
bind dcc - down services_shielddown
bind dcc - up services_shieldup
bind dcc - pass services_pass
bind dcc - nickname services_nick
bind pub n|n ${blah}down shield_downpub
bind pub n|n ${blah}up shield_uppub
bind need - * cs:need


proc services_ident {nick channel type} {
global nickname nickserv
 if {[lsearch -exact [channel info $channel] -csneed] != -1} { return 0 } 
 switch -- $type
set fs [open $pass r]
set pass [read $fs 32]
close $fs
putserv "NickServ :identify $nickname $pass"
}

proc services_ping {nick uhost hand args} {
putlog "PING: Trying to ping chanserv"
putserv "PRIVMSG $chanserv :\001PING"
}

proc services_op {nick uhost hand args} {
global botnick chanserv channame
putserv "PRIVMSG $chanserv :OP $channame $botnick"
}

proc services_check {nick uhost hand chan arg} {
global botnick channame chanserv
if {![botisop $channame] && [botonchan $channame] } {
putserv "PRIVMSG $chanserv :\001PING $chanserv"
 }
}

proc pub:ident {channel type args} {
global nickname nickserv file pass
if {[lsearch -exact [channel info $channel] -csneed] != -1} { return 0 }
 switch -- $type
set fs [open $pass r]
set info [read $fs 32]
putserv "NickServ :identify $info"
close $fs
}

proc pub:op {nick host hand chan text} {
global botnick chanserv channame
putserv "PRIVMSG $chanserv :OP $chan $botnick"
}
proc services_autoreop {nick uhost hand chan deop deopd} {
global botnick channame
if {[matchattr $hand n|m]} { return }
if {([string match -nocase $deopd $botnick]) } {
putserv "ChanServ op $channame $botnick"
 }
}
proc services_autounban {chan unban} {
global channame botnick
putserv "ChanServ unban $channame"
}
proc services_memo {hand idx text} {
global memoserv
putserv "PRIVMSG $memoserv $text"
}

proc services_shielddown {hand idx arg} {
global botnick
putserv "MODE $botnick -R"
}

proc services_shieldup {hand idx arg} {
global botnick
putserv "MODE $botnick +R"
}

proc shield_downpub {nick host hand chan text} {
global botnick
putserv "MODE $botnick -R"
}

proc shield_uppub {nick host hand chan text} {
global botnick
putserv "MODE $botnick +R"
}

setudef flag csneed

bind need - * cs:need 
proc cs:need {channel type} { 
  global botnick 
  if {[lsearch -exact [channel info $channel] -csneed] != -1} { return 0 } 
  switch -- $type {
    "unban" {
      putserv "chanserv :unban $channel $botnick"
    return 1 }
    "invite" {
      putserv "chanserv :invite $channel $botnick"
    return 1 }
    "limit" {
      putserv "chanserv :invite $channel $botnick"
    return 1 }
  }
}
proc services_pass {hand idx text} {
global pass
if {![matchattr $hand n]} { return }
set fs [open $pass w]
puts $fs "$text"
putlog "Services: Nickpass has been set to ****"
close $fs

}
proc services_nick {hand idx text} {
global nicknametxt
if {![matchattr $hand n]} { return }
set fs [open $nicknametxt w]
puts $fs "$text"
close $fs
putlog "Services: Nickname has been set to $text"

}
Ok, So far this is where I'm at however with the proc pub_ident I get this error [20:16] Tcl error [pub:ident]: no such channel record. I can't figure out why or how to fix it?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

See tcl-commands.doc

pub:ident looks like it is intended to allow request to identify via a channel command.

However, the proc definition is well out of whack.

Code: Select all

proc pub:ident {channel type args} {
tcl-commands.doc will tell you what arguments are sent in what order.

Tcl does not guess what information you want placing where. It will do things, and set things in the order they are sent.

EG

Code: Select all

proc testing {this that} {
puts stdout "THIS: $this"
puts stdout "THAT: $that"
}

set this "Hello"
set that "all"
testing $this $that
testing $that $this
Will print
THIS: Hello
THAT: all
THIS: all
THAT: Hello
Just because that name of the variable matches, it doesn't mean the contents will. The same applies in your script, even though you have a variable called channel, it doesn't mean it will contain a channel name. It will simply hold the contents of the information destined for that argument position.
G
Gothic-Angel
Op
Posts: 109
Joined: Mon Sep 23, 2002 9:46 pm

Post by Gothic-Angel »

I basically want the majority of the procs to be activated only if the channel is set to +services in the chanset. A few procs will stay out and be activated at any time.
So how could I go about making the procs only work on a channel if it's set to +services?
Locked