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 

Only bot can set channel mode lock (Dalnet network)
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Sydneybabe
Op


Joined: 27 Apr 2007
Posts: 106
Location: Philippines

PostPosted: Tue Aug 02, 2011 4:34 am    Post subject: Only bot can set channel mode lock (Dalnet network) Reply with quote

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:

Quote:
* Operator sets mode: +mRsC
*Eggdrop sets mode: -mRsC


and eggdrop notice the operator "Please let me handle the channel mode settings."

Thanks in advance. Very Happy
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Wed Aug 03, 2011 2:11 am    Post subject: Reply with quote

Code:

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.
Back to top
View user's profile Send private message
Sydneybabe
Op


Joined: 27 Apr 2007
Posts: 106
Location: Philippines

PostPosted: Thu Aug 04, 2011 3:17 am    Post subject: Reply with quote

Hi sir caesar yep when an operator set mode to +m or +R or +M the bot will not response only to +mRsC
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Mon Aug 08, 2011 1:36 am    Post subject: Reply with quote

Code:

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.
Back to top
View user's profile Send private message
Sydneybabe
Op


Joined: 27 Apr 2007
Posts: 106
Location: Philippines

PostPosted: Tue Aug 09, 2011 6:19 am    Post subject: Reply with quote

Hello caesar i am receiving an error:

Quote:
Tcl error [mode:check]: can't read "modes": no such variable

and
Quote:
Tcl error [mode:check]: invalid command name "isset"
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Aug 09, 2011 2:32 pm    Post subject: Reply with quote

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:
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:
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".
_________________
NML_375, idling at #eggdrop@IrcNET


Last edited by nml375 on Fri Aug 12, 2011 12:22 pm; edited 2 times in total
Back to top
View user's profile Send private message
Sydneybabe
Op


Joined: 27 Apr 2007
Posts: 106
Location: Philippines

PostPosted: Tue Aug 09, 2011 11:55 pm    Post subject: Reply with quote

Hi nml375 can i ask what is the code you provide well do and i load it but i seen an error at partyline:

Quote:
Tcl error [raw:modeCheck]: bad option "-mM": must be -exact, -glob, -indexvar, -matchvar, -nocase, -regexp, or --
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Wed Aug 10, 2011 4:08 am    Post subject: Reply with quote

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

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. Smile
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
Sydneybabe
Op


Joined: 27 Apr 2007
Posts: 106
Location: Philippines

PostPosted: Fri Aug 12, 2011 2:51 am    Post subject: Reply with quote

Hello sir i add this script of into my bot

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


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri Aug 12, 2011 12:17 pm    Post subject: Reply with quote

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:
.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:
--- 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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Sydneybabe
Op


Joined: 27 Apr 2007
Posts: 106
Location: Philippines

PostPosted: Sat Aug 13, 2011 2:58 am    Post subject: Reply with quote

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


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Aug 13, 2011 8:15 am    Post subject: Reply with quote

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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Sydneybabe
Op


Joined: 27 Apr 2007
Posts: 106
Location: Philippines

PostPosted: Sat Aug 13, 2011 8:34 am    Post subject: Reply with quote

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


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Aug 13, 2011 8:43 am    Post subject: Reply with quote

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:
nml375@linux:~/eggdrop1.6.20$ patch -p1 modelock.patch

You should then see some output similar to this:
Code:
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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Sydneybabe
Op


Joined: 27 Apr 2007
Posts: 106
Location: Philippines

PostPosted: Tue Aug 16, 2011 2:28 am    Post subject: Reply with quote

Is this the huge chunk of code are you referring sir nml375?
Code:
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.
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
Goto page 1, 2  Next
Page 1 of 2

 
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