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.

channel mode restrictions

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

channel mode restrictions

Post by simo »

greetz gentz,

we have been using this tcl for a while and on some ircds it works fine but recently we tried it on dalnet and it seems to output odd results

Code: Select all

namespace eval modecontrol {
  variable enforceModes "nt"  #Always keep these set
  variable restrictModes "+ikl" #Never permit these to be set

  proc raw:modeCheck {from key text} {
    variable enforceModes
    variable restrictModes

    set from [split $from "!"]
    set nick [lindex $from 0]
    set handle [nick2hand $nick]
    #Sanity check
    if {[isbotnick $nick] || [matchattr $handle "+mnb"]} { return 0 }

    set items [split $text]
    set enforce [split $enforceModes ""]
    set restrict [split $restrictModes ""]
    set target [lindex $items 0]
    set add 1
    set act 0

     if {[matchattr [nick2hand $nick] n $target] || [isbotnick $nick]} { return 0 }

    foreach mode [split [lindex $items 1] ""] {
      switch -- $mode {
        "+" {
          set add 1
        }
        "-" {
          set add 0
        }
        "I" -
        "e" -
        "b" {
          set items [lreplace $items 2 2]
        }
        "k" {
          if {$add} {
            set key [lindex $items 2]
            set items [lreplace $items 2 2]
          }
        }
        "l" {
          if {$add} {
            set limit [lindex $items 2]
            set items [lreplace $items 2 2]
          }
        }
        default {
          if {[lsearch $enforce $mode] >= 0 && !$add} {
              pushmode $target "+$mode"
            set act 1
          } elseif {[lsearch $restrict $mode] >= 0 && $add} {
            pushmode $target "-$mode"
            set act 1
          }
        }
      }
      #Uncomment this to bounce key and limits
      if {[info exists key]} {
        pushmode $target -k $key
      }
      if {[info exists limit]} {
        pushmode $target -l
      }
    }
    if {$act && [llength $from] > 1} {
      #puthelp "NOTICE $nick :Please let me handle the channel mode settings."
    }
  flushmode $target
    return 0
  }
  bind raw - "MODE" [namespace current]::raw:modeCheck
}


15:55:28 @Motley Sets Mode on #test to: +l 22
15:55:28 @Silver-Eagle Sets Mode on #test to: -lk MODE
15:55:33 @Motley Sets Mode on #test to: -l
15:55:33 @Silver-Eagle Sets Mode on #test to: -k MODE
15:55:45 @Motley Sets Mode on #test to: -k kjdkjd
15:55:45 @Silver-Eagle Sets Mode on #test to: -k MODE
15:55:50 @Motley Sets Mode on #test to: +k kjdkjd
15:55:50 @Silver-Eagle Sets Mode on #test to: -k kjdkjd
15:55:59 @Motley Sets Mode on #test to: +v Motley
15:55:59 @Silver-Eagle Sets Mode on #test to: -k MODE
15:56:11 @Motley Sets Mode on #test to: +o Motley
15:56:11 @Silver-Eagle Sets Mode on #test to: -k MODE

while what is expected is

@Motley Sets Mode on #test to: +l 22
@Motley Sets Mode on #test to: -l
@Motley Sets Mode on #test to: -k kjdkjd
@Motley Sets Mode on #test to: +k kjdkjd
@Silver-Eagle Sets Mode on #test to: -k kjdkjd
@Motley Sets Mode on #test to: +v Motley
@Motley Sets Mode on #test to: +o Motley

Last edited by simo on Sat Oct 01, 2022 1:31 pm, edited 1 time in total.
User avatar
CrazyCat
Revered One
Posts: 1217
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Looks like dalnet doesn't sends mode message like other networks.

putlog $text to know how are formated message, and then you can adapt your script.
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thanks for the reply CrazyCat i did just that but couldnt figure whats wrong
User avatar
CrazyCat
Revered One
Posts: 1217
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

I've a short stupi idea: why don't show us the content of $text if you want to be helped ?

my 2 cents.
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i used this :

Code: Select all


namespace eval modecontrol {
  variable enforceModes "nt"  #Always keep these set
  variable restrictModes "+ikl" #Never permit these to be set

  proc raw:modeCheck {from key text} {
    variable enforceModes
    variable restrictModes

    set from [split $from "!"]
    set nick [lindex $from 0]
    set handle [nick2hand $nick]
    #Sanity check
  #  if {[isbotnick $nick] || [matchattr $handle "+mnb"]} { return 0 }

    set items [split $text]
    set enforce [split $enforceModes ""]
    set restrict [split $restrictModes ""]
    set target [lindex $items 0]
    set add 1
    set act 0

#     putserv "privmsg $target :$restrict"
#      putserv "privmsg $target :[split [lindex $items 1] ""]"
  
  #   if {[matchattr [nick2hand $nick] n $target] || [isbotnick $nick]} { return 0 }

    foreach mode [split [lindex $items 1] ""] {
     # putserv "privmsg $target :$mode"
      switch -- $mode {
        "+" {
          set add 1
        }
        "-" {
          set add 0
        }
        "I" -
        "e" -
        "b" {
          set items [lreplace $items 2 2]
        }
        "k" {
          if {$add} {
            set key [lindex $items 2]
            set items [lreplace $items 2 2]
           putserv "privmsg $target :$key - $items" 
          }
        }
        "l" {
          if {$add} {
            set limit [lindex $items 2]
            set items [lreplace $items 2 2]
          }
        }
        default {
          if {[lsearch $enforce $mode] >= 0 && !$add} {
            # pushmode $target "+$mode"
            putserv "privmsg $target +$mode"
            set act 1
          } elseif {[lsearch $restrict $mode] >= 0 && $add} {
          #  pushmode $target "-$mode"
            putserv "privmsg $target -$mode"
            set act 1
          }
        }
      }
      #Uncomment this to bounce key and limits
      if {[info exists key]} {
        # pushmode2 $target -k $key
          putserv "privmsg $target -k $key "
      }
      if {[info exists limit]} {
       #  pushmode $target -l
          putserv "privmsg $target -l"
      }
    }
    if {$act && [llength $from] > 1} {
      #puthelp "NOTICE $nick :Please let me handle the channel mode settings."
    }
  flushmode $target
    return 0
  }
  bind raw - "MODE" [namespace current]::raw:modeCheck
}

with this output:

21:53:42 @El-dente Sets Mode on #TEST to: -k 8732
21:53:42 (@Silver-Eagle) : -k MODE
21:53:42 (@Silver-Eagle) : -k MODE
21:53:51 @El-dente Sets Mode on #TEST to: +k 8732
21:53:51 (@Silver-Eagle) : -k MODE
21:53:51 (@Silver-Eagle) : 8732 - {#TEST} +k
21:53:51 (@Silver-Eagle) : -k 8732
21:55:04 @El-dente Sets Mode on #TEST to: +v El-dente
21:55:04 (@Silver-Eagle) : -k MODE
21:55:04 (@Silver-Eagle) : -k MODE
21:55:10 @El-dente Sets Mode on #TEST to: -v El-dente
21:55:10 (@Silver-Eagle) : -k MODE
21:55:10 (@Silver-Eagle) : -k MODE
21:55:18 El-dente Sets Mode on #TEST to: -o El-dente
21:55:18 (@Silver-Eagle) : -k MODE
21:55:18 (@Silver-Eagle) : -k MODE
21:55:23 @El-dente Sets Mode on #TEST to: +o El-dente
21:55:23 (@Silver-Eagle) : -k MODE
21:55:23 (@Silver-Eagle) : -k MODE

21:58:27 @Cappuccino Sets Mode on #TEST to: +i
21:58:27 (@Silver-Eagle) : -k MODE
21:58:27 (@Silver-Eagle) : -i
21:58:27 (@Silver-Eagle) : -k MODE
User avatar
CrazyCat
Revered One
Posts: 1217
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Ok, i think you don't read what I propose to help you.

1. add a f***ing putlog $text in your proc
2. copy here what you see in PL (so the f***ing $text)
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

Inspircd server

#test :+i
#test -v :Campbell
#test +k :keyword
#test +l :67

Bahamut ircd (Dalnet server)

#test +k keyword
#test +v Campbell
#test +i
#test +l 293

These are the ircds we generally use
User avatar
CrazyCat
Revered One
Posts: 1217
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Ok, understoud your error.
Your proc is defined with:

Code: Select all

proc raw:modeCheck {from key text} {
And after you use a variable with the same name (key:

Code: Select all

set key [lindex $items 2]
...
if {[info exists key]} { 
   putserv "privmsg $target -k $key "
Rename the variable to ckey (as Channel Key) or anything you want and it will work
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

Thanks CrazyCat
Post Reply