mirror of
https://github.com/znc/znc.git
synced 2026-08-06 17:03:14 +02:00
Added support for bind msg/msgm.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
#
|
||||
# Binds module to process incoming messages with ZNC modtcl
|
||||
#
|
||||
# Supported bind types: pubm/pub, time, evnt, nick, bot, dcc, kick
|
||||
# Supported bind types: pub/pubm, msg/msgm, time, evnt, nick, bot, dcc, kick
|
||||
# evnt: prerehash,rehash,init-server,disconnect-server
|
||||
#
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace eval Binds {
|
||||
|
||||
# procs
|
||||
proc Add {type flags cmd {procname ""}} {
|
||||
if {![regexp {^(pub|pubm|nick|mode|raw|bot|time|evnt|dcc|kick)$} $type]} {
|
||||
if {![regexp {^(pub|pubm|msg|msgm|nick|mode|raw|bot|time|evnt|dcc|kick)$} $type]} {
|
||||
PutModule "Tcl error: Bind type: $type not supported"
|
||||
return
|
||||
}
|
||||
@@ -53,13 +53,29 @@ namespace eval Binds {
|
||||
}
|
||||
foreach {type flags mask hits proc} [join [binds pubm]] {
|
||||
regsub {^%} $mask {*} mask
|
||||
if {[ModuleLoaded crypt]} {regsub {^¤} $nick {} nick}
|
||||
if {[ModuleLoaded crypt]} {regsub {^\244} $nick {} nick}
|
||||
if {[string match -nocase $mask "$channel $text"]} {
|
||||
$proc $nick $user $handle $channel $text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
proc ProcessMsgm {nick user handle text} {
|
||||
# Loop bind list and execute
|
||||
foreach n [binds msg] {
|
||||
if {[string match [lindex $n 2] [lindex [split $text] 0]]} {
|
||||
[lindex $n 4] $nick $user $handle [lrange [join $text] 1 end]
|
||||
}
|
||||
}
|
||||
foreach {type flags mask hits proc} [join [binds msgm]] {
|
||||
regsub {^%} $mask {*} mask
|
||||
if {[ModuleLoaded crypt]} {regsub {^\244} $nick {} nick}
|
||||
if {[string match -nocase $mask "$text"]} {
|
||||
$proc $nick $user $handle $text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
proc ProcessTime {} {
|
||||
if {[clock format [clock seconds] -format "%S"] != 0} {return}
|
||||
set time [clock format [clock seconds] -format "%M %H %d %m %Y"]
|
||||
@@ -137,4 +153,4 @@ proc ::unbind {type flags cmd procname} {Binds::Del $type $flags $cmd $procname}
|
||||
proc ::binds {{type ""}} {if {$type != ""} {set type "$type "};return [lsearch -all -inline $Binds::List "$type*"]}
|
||||
proc ::bindlist {{type ""}} {foreach bind $Binds::List {PutModule "$bind"}}
|
||||
|
||||
PutModule "modtcl script loaded: Binds v0.1"
|
||||
PutModule "modtcl script loaded: Binds v0.2"
|
||||
|
||||
Reference in New Issue
Block a user