Tkabber contrib

Check-in [adabe332a8]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:alarm.tcl: Got rid of [cequal] calls because this command is about to be deleted from Tkabber.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:adabe332a87848e30704544c9ab92ac1b5182b45
User & Date: sgolovan 2015-03-30 06:56:25
Context
2015-03-30
07:02
Got rid of [lcontain] and [cequal] calls because they are about to be removed from Tkabber. check-in: b34ad81538 user: sgolovan tags: trunk
06:56
alarm.tcl: Got rid of [cequal] calls because this command is about to be deleted from Tkabber. check-in: adabe332a8 user: sgolovan tags: trunk
2014-04-27
16:33
Juick plugin (svn branch): * Add undocumented [title](URL) link style. check-in: 877af5cf07 user: toktonada tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to alarm/alarm.tcl.

111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
...
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
...
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
...
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
        -command [list [namespace current]::get_response $jid]
}

proc alarm::get_response {jid res child} {
    debugmsg plugins "alarm: response from $jid res: $res child: $child"


    if { [cequal $res OK] } {
	::set_status [format [::msgcat::mc "%s was alarmed"] $jid]
    } else {
	lassign [error_type_condition $child] type condition
	set reason [format [::msgcat::mc "%s rejects your alarm: "] $jid]
	     
	switch -- $condition {
	    not-acceptable { append reason [::msgcat::mc "antiflood"] }
................................................................................
    set full_jid $from
    
    catch {set subsc $::roster::roster(subsc,$xlib,$jid)}
    catch {set groups $::roster::roster(group,$xlib,$jid)}

    # Firstly, check JIDs
    foreach elem $options(denied_jids) {
	if { [cequal $server $elem] || [cequal $jid $elem] || [cequal $full_jid $elem] } {
	    return 0
	}
    }

    foreach elem $options(allowed_jids) {
	if { [cequal $server $elem] || [cequal $jid $elem] || [cequal $full_jid $elem] } {
	    return 1
	}
    } 
    
    # Then groups
    foreach elem $options(denied_groups) {
	foreach group $groups { 
	    if { [cequal $group $elem] } {return 0}
	}
    }

    foreach elem $options(allowed_groups) {
	foreach group $groups { 
	    if { [cequal $group $elem] } {return 1}
	}
    }
    
    # And at the end apply default rule
    switch -- $options(default_rule) {
	deny_to_all { return 0 }
	allow_all { return 1 } 
	only_registered {
	    return [expr [cequal $subsc both] || [cequal $subsc from] || [cequal $subsc to] ]
	}
    }

    return 0;
}

proc alarm::antiflood {xlib from} {
................................................................................
# incoming message handler

proc alarm::message_proc {xlib from id type is_subject subject body err thread priority x} {
    variable options

    set myjid [connection_jid $xlib]

    if {![cequal $type chat] 
	|| (!$options(enabled))
	|| [cequal $from $myjid]
	|| (![apply_filter $xlib $from])
	|| (![antiflood $xlib $from]) } { 
	return 
    }
    
    if {![cequal $options(keymessage) ""]
	&& [regexp $options(keymessage) $body]} {
	after idle [list [namespace current]::show_alarm $xlib $from]	
	return
    }

    if {$options(ding_support_in)
	&& [string match *<ding>* $body]} {
................................................................................
    }
}


proc alarm::disco_info_handler {xlib jid args} {

    lassign $args result identities features extras
    if {![cequal $result OK]} return
    
    foreach feature $features {

	set var [xmpp::xml::getAttr $feature var]
	if {![cequal $var $::NS(plugins_alarm)]} continue
	
	send_alarm0 $xlib $jid
	return
    }
    

    xmpp::sendMessage $xlib $jid -body <ding>

} 

# vim:ts=8:sw=4:sts=4:et







|







 







|





|







|





|








|







 







|

|





|







 







|




|











111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
...
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
...
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
...
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
        -command [list [namespace current]::get_response $jid]
}

proc alarm::get_response {jid res child} {
    debugmsg plugins "alarm: response from $jid res: $res child: $child"


    if { $res eq "ok" } {
	::set_status [format [::msgcat::mc "%s was alarmed"] $jid]
    } else {
	lassign [error_type_condition $child] type condition
	set reason [format [::msgcat::mc "%s rejects your alarm: "] $jid]
	     
	switch -- $condition {
	    not-acceptable { append reason [::msgcat::mc "antiflood"] }
................................................................................
    set full_jid $from
    
    catch {set subsc $::roster::roster(subsc,$xlib,$jid)}
    catch {set groups $::roster::roster(group,$xlib,$jid)}

    # Firstly, check JIDs
    foreach elem $options(denied_jids) {
	if { $server eq $elem || $jid eq $elem || $full_jid eq $elem } {
	    return 0
	}
    }

    foreach elem $options(allowed_jids) {
	if { $server eq $elem || $jid eq $elem || $full_jid eq $elem } {
	    return 1
	}
    } 
    
    # Then groups
    foreach elem $options(denied_groups) {
	foreach group $groups { 
	    if { $group eq $elem } {return 0}
	}
    }

    foreach elem $options(allowed_groups) {
	foreach group $groups { 
	    if { $group eq $elem } {return 1}
	}
    }
    
    # And at the end apply default rule
    switch -- $options(default_rule) {
	deny_to_all { return 0 }
	allow_all { return 1 } 
	only_registered {
	    return [expr {$subsc eq "both" || $subsc eq "from" || $subsc eq "to"} ]
	}
    }

    return 0;
}

proc alarm::antiflood {xlib from} {
................................................................................
# incoming message handler

proc alarm::message_proc {xlib from id type is_subject subject body err thread priority x} {
    variable options

    set myjid [connection_jid $xlib]

    if {$type ne "chat" 
	|| (!$options(enabled))
	|| $from eq $myjid
	|| (![apply_filter $xlib $from])
	|| (![antiflood $xlib $from]) } { 
	return 
    }
    
    if {$options(keymessage) ne ""
	&& [regexp $options(keymessage) $body]} {
	after idle [list [namespace current]::show_alarm $xlib $from]	
	return
    }

    if {$options(ding_support_in)
	&& [string match *<ding>* $body]} {
................................................................................
    }
}


proc alarm::disco_info_handler {xlib jid args} {

    lassign $args result identities features extras
    if {$result ne "ok"} return
    
    foreach feature $features {

	set var [xmpp::xml::getAttr $feature var]
	if {$var ne $::NS(plugins_alarm)} continue
	
	send_alarm0 $xlib $jid
	return
    }
    

    xmpp::sendMessage $xlib $jid -body <ding>

} 

# vim:ts=8:sw=4:sts=4:et