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 

channel mode restrictions

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Sat Oct 01, 2022 9:57 am    Post subject: channel mode restrictions Reply with quote

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:

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
}




Quote:


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

Quote:


@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
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1108
Location: France

PostPosted: Sat Oct 01, 2022 12:30 pm    Post subject: Reply with quote

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.
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Sat Oct 01, 2022 12:56 pm    Post subject: Reply with quote

thanks for the reply CrazyCat i did just that but couldnt figure whats wrong
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1108
Location: France

PostPosted: Sat Oct 01, 2022 2:49 pm    Post subject: Reply with quote

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

my 2 cents.
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Sat Oct 01, 2022 3:57 pm    Post subject: Reply with quote

i used this :

Code:


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:

Quote:


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

Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1108
Location: France

PostPosted: Sat Oct 01, 2022 4:27 pm    Post subject: Reply with quote

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)
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Sat Oct 01, 2022 9:11 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1108
Location: France

PostPosted: Sun Oct 02, 2022 7:37 am    Post subject: Reply with quote

Ok, understoud your error.
Your proc is defined with:
Code:
proc raw:modeCheck {from key text} {


And after you use a variable with the same name (key:
Code:
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
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Sun Oct 02, 2022 8:07 am    Post subject: Reply with quote

Thanks CrazyCat
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 -> Script Requests 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