Formatting of code : You can (and must) use [ tcl ] an [ /tcl ] tags (without spaces in tags) to format your TCL codes and have syntax coloration x


greet user based on their flags
#1
Hi all, i would like to request a small scripts to greet users based on their flags when join specific channel.


Example:


Code:
[16:43] * mabrook (~mabrook@46.49.103.62) has joined #mabrook
[16:43] * ChanServ sets mode: +o mabrook
[16:43] <@Bot> [mabrook] Yahoo... here we go. Welcome mabrook ;)
the bot will greet the users with sop/aop flags to the channel. 


thank you in advance.
  Reply
#2
Well, eggdrop doesn't know the ChanServ's access list of the channel, so it can't make any difference between OP, SOP and AOP unless your server send the extra modes (& and ~).
The only solution I can see is to set SOP and AOP as +n of channel in the eggdrop userlist, and then having a script to greet only the +n.
irc.zeolia.net - Offrez-moi un café
Merci de ne pas demander d'aide en MP
Away
  Reply
#3
yes @ CrazyCat that's what I'm thinking awhile ago but I need to confirm it from here :) . Thank you for the reply.
  Reply
#4
hello @ CrazyCat , i found this script from the other forum; it will give +v to all registered users in dalnet in specific channel.

if we can add a random message (.txt file) after giving a voice to the user.



tcl
# SYNTAX (on PartyLine/DCC/CTCP/TELnet): .chanset #channel -/+checkisauth
# ----------
# PUBCMD:
# !checkisreg on|off
# ----------
# MSGCMD:
# /msg botnick checkisreg #channel on|off
 
namespace eval RegVoice {
    variable verifieduser "*has identified for*"
    setudef flag checkisauth
 
    bind join - * [namespace current]::joinCheck
    bind raw - 307 [namespace current]::isReg
    bind pub o|o !checkisreg [namespace current]::public
    bind msg o|o checkisreg [namespace current]::message
     
    bind time - * [namespace current]::cleanUp
 
    proc cleanUp {minute hour day month year} {
       global checkAuth
       if {[info exists checkAuth]} {
          foreach nick $checkAuth {
             if {![onchan $nick]} {
                set pos [lsearch -nocase $nick $checkAuth]
                set checkAuth [lreplace $checkAuth $pos $pos]
             }
          }
       }
    }
     
    proc joinCheck {nick uhost hand chan} {
       global checkAuth
       if {[isbotnick $nick]} return
       if {![channel get $chan checkisauth] || [validuser $hand]} return
       if {[info exists checkAuth]} {
          if {[lsearch -nocase $nick $checkAuth] != -1} return
       }
       lappend checkAuth $nick
       puthelp "WHOIS $nick"
    }
 
    proc isReg {from keyword text} {
       global checkAuth
       variable verifieduser
 
       set nick [lindex [split $text] 1]
       if {[info exists checkAuth]} {
          set pos [lsearch -nocase $nick $checkAuth]
          if {$pos != -1} {
             set checkAuth [lreplace $checkAuth $pos $pos]
          }
       }
       if {![string match "*has identified for*" $text]} return
       if {[validuser [nick2hand $nick]]} return
       foreach chan [channels] {
				if {![channel get $chan checkisauth] || ![onchan $nick $chan] || [isop $nick $chan] || [isvoice $nick $chan]} continue
          if {![botisop $chan]} continue
          pushmode $chan +v $nick
       }
    }
     
    proc public {nick uhost hand chan text} {
       if {[scan $text {%s} mode] != 1} {
         puthelp "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: !checkisreg on|off"
         return
       }
       doAction $mode $chan $chan
    }
 
    proc message {nick uhost hand chan text} {
       if {[scan $text {%s%s} mode channel] != 2} {
          puthelp "PRIVMSG $nick :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: checkisreg #channel on|off"
          return
       }
       if {[string first # $channel] != 0} {
          puthelp "PRIVMSG $nick :\037ERROR\037: Provided channel doesn't seem to correct. \037SYNTAX\037: checkisreg #channel on|off"
          return
       }
       doAction $mode $channel $nick
    }
 
    proc doAction {mode chan dest} {
       if {![validchan $channel] || ![botonchan $channel]} {
          puthelp "PRIVMSG $dest ::\037ERROR\037: Channel $chan doesn't exist in my database or I'm not on it."
          return
       }
       set status [channel get $chan checkisauth]
       switch -- [string tolower $mode] {
          "on" {
             if {$status} {
                puthelp "PRIVMSG $dest :\037ERROR\037: This setting is already enabled."
             } else {
                channel set $chan +checkisauth
                puthelp "PRIVMSG $dest :Enabled Automatic Register Checking for $chan"
             }
          }
          "off" {
             if {!$status} {
                puthelp "PRIVMSG $dest :\037ERROR\037: This setting is already disabled."
             } else {
                channel set $chan -checkisauth
                puthelp "PRIVMSG $dest :Disabled Automatic Register Checking for $chan"
             }
          }
          default {
             if {![string first # $dest]} {
                puthelp "PRIVMSG $dest :\037ERROR\037: $mode is not an accepted parameter. \037SYNTAX\037: !checkisreg on|off"
             } else {
                puthelp "PRIVMSG $dest :\037ERROR\037: $mode is not an accepted parameter. \037SYNTAX\037: checkisreg #channel on|off"
             }
          }
       }
    }
 }
 
 
putlog "registerednick.tcl loaded"



if we can merge it here.  Very Happy
  Reply
#5
All you have to do is to create a little script:

tcl
namespace eval rgreet {
 
   variable gtext "greets.txt"
 
   proc getrand {} {
      set fi [open $::rgreet::gtext r]
      set lines [split [read -nonewline $fi] "\n"]
      close $fi
      return [lindex $lines [rand [llength $lines]]]
}

Ensure you have a greets.txt file with the different greets (one per line), load the script and modify the Regvoice script like this:

find pushmode $chan +v $nick
after, add: putserv "PRIVMSG $chan :[::rgreet::getrand]"
irc.zeolia.net - Offrez-moi un café
Merci de ne pas demander d'aide en MP
Away
  Reply
#6
THank you @ CrazyCat 



Code:
# SYNTAX (on PartyLine/DCC/CTCP/TELnet): .chanset #channel -/+checkisauth
# ----------
# PUBCMD:
# !checkisreg on|off
# ----------
# MSGCMD:
# /msg botnick checkisreg #channel on|off

namespace eval rgreet {

   variable gtext "scripts/greets.txt"

   proc getrand {} {
      set fi [open $::rgreet::gtext r]
      set lines [split [read -nonewline $fi] "\n"]
      close $fi
      return [lindex $lines [rand [llength $lines]]]
}
}
namespace eval RegVoice {
    variable verifieduser "*has identified for*"
    setudef flag checkisauth

    bind join - * [namespace current]::joinCheck
    bind raw - 307 [namespace current]::isReg
    bind pub o|o !checkisreg [namespace current]::public
    bind msg o|o checkisreg [namespace current]::message
    
    bind time - * [namespace current]::cleanUp

    proc cleanUp {minute hour day month year} {
       global checkAuth
       if {[info exists checkAuth]} {
          foreach nick $checkAuth {
             if {![onchan $nick]} {
                set pos [lsearch -nocase $nick $checkAuth]
                set checkAuth [lreplace $checkAuth $pos $pos]
             }
          }
       }
    }
    
    proc joinCheck {nick uhost hand chan} {
       global checkAuth
       if {[isbotnick $nick]} return
       if {![channel get $chan checkisauth] || [validuser $hand]} return
       if {[info exists checkAuth]} {
          if {[lsearch -nocase $nick $checkAuth] != -1} return
       }
       lappend checkAuth $nick
       puthelp "WHOIS $nick"
    }

    proc isReg {from keyword text} {
       global checkAuth
       variable verifieduser

       set nick [lindex [split $text] 1]
       if {[info exists checkAuth]} {
          set pos [lsearch -nocase $nick $checkAuth]
          if {$pos != -1} {
             set checkAuth [lreplace $checkAuth $pos $pos]
          }
       }
       if {![string match "*has identified for*" $text]} return
       if {[validuser [nick2hand $nick]]} return
       foreach chan [channels] {
                if {![channel get $chan checkisauth] || ![onchan $nick $chan] || [isop $nick $chan] || [isvoice $nick $chan]} continue
          if {![botisop $chan]} continue
          pushmode $chan +v $nick
          putserv "PRIVMSG $chan :[::rgreet::getrand]"
       }
    }
    
    proc public {nick uhost hand chan text} {
       if {[scan $text {%s} mode] != 1} {
         puthelp "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: !checkisreg on|off"
         return
       }
       doAction $mode $chan $chan
    }

    proc message {nick uhost hand chan text} {
       if {[scan $text {%s%s} mode channel] != 2} {
          puthelp "PRIVMSG $nick :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: checkisreg #channel on|off"
          return
       }
       if {[string first # $channel] != 0} {
          puthelp "PRIVMSG $nick :\037ERROR\037: Provided channel doesn't seem to correct. \037SYNTAX\037: checkisreg #channel on|off"
          return
       }
       doAction $mode $channel $nick
    }

    proc doAction {mode chan dest} {
       if {![validchan $channel] || ![botonchan $channel]} {
          puthelp "PRIVMSG $dest ::\037ERROR\037: Channel $chan doesn't exist in my database or I'm not on it."
          return
       }
       set status [channel get $chan checkisauth]
       switch -- [string tolower $mode] {
          "on" {
             if {$status} {
                puthelp "PRIVMSG $dest :\037ERROR\037: This setting is already enabled."
             } else {
                channel set $chan +checkisauth
                puthelp "PRIVMSG $dest :Enabled Automatic Register Checking for $chan"
             }
          }
          "off" {
             if {!$status} {
                puthelp "PRIVMSG $dest :\037ERROR\037: This setting is already disabled."
             } else {
                channel set $chan -checkisauth
                puthelp "PRIVMSG $dest :Disabled Automatic Register Checking for $chan"
             }
          }
          default {
             if {![string first # $dest]} {
                puthelp "PRIVMSG $dest :\037ERROR\037: $mode is not an accepted parameter. \037SYNTAX\037: !checkisreg on|off"
             } else {
                puthelp "PRIVMSG $dest :\037ERROR\037: $mode is not an accepted parameter. \037SYNTAX\037: checkisreg #channel on|off"
             }
          }
       }
    }
}


putlog "registerednick.tcl by Pororo loaded"




it works perfect, but the message will go first then the +v :)))
  Reply
#7
Add flushmode $chan after the pushmode line and replace putserv "PRIVMSG $chan :[::rgreet::getrand]" with puthelp "PRIVMSG $chan :[::rgreet::getrand]"
irc.zeolia.net - Offrez-moi un café
Merci de ne pas demander d'aide en MP
Away
  Reply
#8
Thank you @ CrazyCat , now is good.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)