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.

Only bot can set channel mode lock (Dalnet network)

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
S
Sydneybabe
Op
Posts: 106
Joined: Fri Apr 27, 2007 3:31 am
Location: Philippines

Only bot can set channel mode lock (Dalnet network)

Post by Sydneybabe »

Hi i need a script that only the bot can set a mode lock on channel because some operators setting a wrong mode lock on channel example:
* Operator sets mode: +mRsC
*Eggdrop sets mode: -mRsC
and eggdrop notice the operator "Please let me handle the channel mode settings."

Thanks in advance. :D
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

bind mode * "% +mRsC" mode:check

proc mode:check {nick uhost handle channel change target} {
if {[isbotnick $nick]} return
pushmode $channel -mRsC
putserv "NOTICE $nick :Please let me handle the channel mode settings."
}
This will work only if the operator had set those modes. If you want something different, just let me know.
Once the game is over, the king and the pawn go back in the same box.
S
Sydneybabe
Op
Posts: 106
Joined: Fri Apr 27, 2007 3:31 am
Location: Philippines

Post by Sydneybabe »

Hi sir caesar yep when an operator set mode to +m or +R or +M the bot will not response only to +mRsC
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

set lockModes "mRsC"

bind mode * * mode:check

proc mode:check {nick uhost handle channel change target} {
	global lockModes
	if {[isbotnick $nick]} return
	foreach m [split $lockModes ""] {
		if {![string match "*$m*" $change]} continue
		lappend modes $m
	}
	if {![isset $modes]} return
	pushmode $channel -$modes
	putserv "NOTICE $nick :Please let me handle the channel mode settings."
}
Haven't tested this but should work.
Once the game is over, the king and the pawn go back in the same box.
S
Sydneybabe
Op
Posts: 106
Joined: Fri Apr 27, 2007 3:31 am
Location: Philippines

Post by Sydneybabe »

Hello caesar i am receiving an error:
Tcl error [mode:check]: can't read "modes": no such variable
and
Tcl error [mode:check]: invalid command name "isset"
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Caesar,
You'll need the raw-binding to catch multiple modes; the mode binding is triggered once for each mode-change within the MODE command.

Porting the above code would look something like this:

Code: Select all

set lockModes "mRsC"

bind raw - "MODE" raw:modeCheck

proc raw:modeCheck {from key text} {
  set nick [lindex [split $from "!"] 0]
  #Sanity check
  if {[isbotnick $nick]} {
    return 0
  }

  set items [split $text]
  set lock [split $::lockModes ""]
  set target [lindex $items 0]
  set add 1
  set act 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 -- $lock $mode] >= 0 && !$add} {
          pushmode $target "+$mode"
          set act 1
        } elseif {[lsearch -- $lock $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} {
      puthelp "NOTICE $nick :Please let me handle the channel mode settings."
    }
  }
  return 0
}
However, unless you really need the notice-part, you could always use the chanmode setting (.chanset #channel chanmode "+mRsC-klint...") to enforce a set of modes.
Actually, thinking of it, you could rely on the chanmode setting, and simply extend with a script to send the actual notice..

Code: Select all

bind raw - "MODE" raw:noticeMode
proc raw:noticeMode {from key text} {
  set nick [lindex [split $from "!"] 0]
  set handle [nick2hand $nick]
  set channel [lindex [split $text] 0]

  #Don't bug owners or bots
  if {![matchattr $handle "+nb"]} {
    puthelp "NOTICE $nick :Please let me handle the channel mode settings."
  }
  return 0
}
Edit: Fixed two issues with the foreach-loop, sorting the problem with "no such option".
Last edited by nml375 on Fri Aug 12, 2011 12:22 pm, edited 2 times in total.
NML_375
S
Sydneybabe
Op
Posts: 106
Joined: Fri Apr 27, 2007 3:31 am
Location: Philippines

Post by Sydneybabe »

Hi nml375 can i ask what is the code you provide well do and i load it but i seen an error at partyline:
Tcl error [raw:modeCheck]: bad option "-mM": must be -exact, -glob, -indexvar, -matchvar, -nocase, -regexp, or --
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Ah crap, you are right. The chanmode setting is easiest approach on this, I wonder why didn't think about that. :)

The 'lsearch' lines are causing that error. Anyway, just go with the second code nml375 posted as is easier to maintain the list of modes you wish to enforce. An user defined flag (setudef) to enable/disable this behavior should be added to make things even more customizable. :)
Once the game is over, the king and the pawn go back in the same box.
S
Sydneybabe
Op
Posts: 106
Joined: Fri Apr 27, 2007 3:31 am
Location: Philippines

Post by Sydneybabe »

Hello sir i add this script of into my bot

Code: Select all

bind raw - "MODE" raw:noticeMode
proc raw:noticeMode {from key text} {
  set nick [lindex [split $from "!"] 0]
  set handle [nick2hand $nick]
  set channel [lindex [split $text] 0]

  #Don't bug owners or bots
  if {![matchattr $handle "+nb"]} {
    puthelp "NOTICE $nick :Please let me handle the channel mode settings."
  }
  return 0
}
and what i did is i added the other bot to +b flags and test but when the bot i added sets mode +M the channel .. the bot that loaded of the script -M the mode.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Unfortunately, it would seem that the built-in modelock only allows overrides from masters, owners, and the bot itself, but not other bots. As for the tcl-script, it does none of the mode enforcements, but merely notifies the offender not to change modes.

You should, however, get away with granting your bots master privileges on the individual channels:

Code: Select all

.chattr otherbot +m #thechannel
You could also apply this patch to the source, in order to permit bots and friends (+f) to override the modelock:

Code: Select all

--- eggdrop1.6.20/src/mod/irc.mod/mode.c        2010-07-01 18:10:49.000000000 +0200
+++ eggdrop1.6.20+modelock/src/mod/irc.mod/mode.c       2011-08-12 18:16:15.256931403 +0200
@@ -1323,7 +1323,8 @@
             if ((((ms2[0] == '+') && (chan->mode_mns_prot & todo)) ||
                 ((ms2[0] == '-') && (chan->mode_pls_prot & todo))) &&
                 !glob_master(user) && !chan_master(user) &&
-                !match_my_nick(nick))
+                !glob_friend(user) && !chan_friend(user) &&
+                !glob_bot(user) && !match_my_nick(nick))
               add_mode(chan, ms2[0] == '+' ? '-' : '+', *chg, "");
             else if (reversing && ((ms2[0] == '+') ||
                      (chan->mode_pls_prot & todo)) && ((ms2[0] == '-') ||
NML_375
S
Sydneybabe
Op
Posts: 106
Joined: Fri Apr 27, 2007 3:31 am
Location: Philippines

Post by Sydneybabe »

It seems i'm having difficulty how to do that thing i just made something like this but just wanted to know you sir if this is correct:

Code: Select all

set timechks 30
timer $timechks snowbotchk

proc snowbotchk {} {
	global timechks
	foreach chan [channels] {
		if {[botisop $chan] && [isbotnick $nick] && ![string equal "Eggdrop" $nick]} {
			if {[string match +*m* [lindex [getchanmode $chan] 0]]} {
				pushmode #bot -m
			}
		} elseif {[string match +*M* [lindex [getchanmode $chan] 0]]} {
			pushmode #bot -M
		}
	} elseif {[string match +*R* [lindex [getchanmode $chan] 0]]} {
		pushmode #bot -R
	}
}
timer $timechks snowbotchk
Thanks in advance.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

I'm afraid that piece of code does not make much sense at all..
No variable named "nick" is ever defined within your "snowbotchk" proc, so you will get an error about that. Even if $nick would've been defined, I don't see the sense in matching it against the string "Eggdrop"...

The foreach-command does not accept any "elseif" options; your braces are mis-aligned.

Finally, if you were to correct the above issues, all your code would do, is to check each channel every 30 minutes, and remove any mMR modes (regardless of who set it initially). As I understood your earlier post, you wanted your eggdrop to permit other bots to change locked modes (override).
NML_375
S
Sydneybabe
Op
Posts: 106
Joined: Fri Apr 27, 2007 3:31 am
Location: Philippines

Post by Sydneybabe »

Yep sir but i don't understand the code you provide how to make it works and i just make a script that i think on that flow i could understand i hope you help me sir with something like that or do i have to make it a new topic.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

The last piece of code I posted is a patch, which is applied to the sourcecode of eggdrop prior compiling. The simplest way of applying it is to write it to a file (say modelock.patch), and from within the eggdrop source directory, issue this command:

Code: Select all

nml375@linux:~/eggdrop1.6.20$ patch -p1 modelock.patch
You should then see some output similar to this:

Code: Select all

patching file src/mod/irc.mod/mode.c
Hunk #1 succeeded at 1323 with fuzz 1.
nml375@linux:~/eggdrop1.6.20$
At this point, you continue with the compiling as usual: ie ./configure; make config; make; make install

Otherwize, I've corrected the huge chunk of code I posted earlier, so that "should" work
NML_375
S
Sydneybabe
Op
Posts: 106
Joined: Fri Apr 27, 2007 3:31 am
Location: Philippines

Post by Sydneybabe »

Is this the huge chunk of code are you referring sir nml375?

Code: Select all

set lockModes "mRsC"

bind raw - "MODE" raw:modeCheck

proc raw:modeCheck {from key text} {
  set nick [lindex [split $from "!"] 0]
  #Sanity check
  if {[isbotnick $nick]} {
    return 0
  }

  set items [split $text]
  set lock [split $::lockModes ""]
  set target [lindex $items 0]
  set add 1
  set act 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 -- $lock $mode] >= 0 && !$add} {
          pushmode $target "+$mode"
          set act 1
        } elseif {[lsearch -- $lock $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} {
      puthelp "NOTICE $nick :Please let me handle the channel mode settings."
    }
  }
  return 0
}
I will try this one and post the result later thanks.
Post Reply