# HG changeset patch # User Matti Hamalainen # Date 1412077678 -10800 # Node ID 4e09bcc48851a18f45792862fff0947a57e4723e # Parent 861a49abee2203cd6a9afc5b65a7460b599c6a00 urllog: Add settings for specifying channels where URL logging is active, and where !urlfind functionality works (separately, if so desired.) diff -r 861a49abee22 -r 4e09bcc48851 urllog.tcl --- a/urllog.tcl Mon Sep 29 05:49:22 2014 +0300 +++ b/urllog.tcl Tue Sep 30 14:47:58 2014 +0300 @@ -45,6 +45,13 @@ ### General options ### +# Channels where URLLog records links/URLs +# set urllog_log_channels "#foobar;#baz" +# You can use * to match substrings or everything +set urllog_log_channels "*" + + + # Filename of the SQLite URL database file set urllog_db_file "urllog.sqlite" @@ -68,10 +75,9 @@ ### Search related settings ### -# 0 = No search-commands available -# 1 = Search enabled -set urllog_search 1 - +# Channels where !urlfind and other commands can be used. +# By default this is set to be the same as urllog_log_channels +set urllog_search_channels $urllog_log_channels # Limit how many URLs should the "!urlfind" command show at most. set urllog_showmax_pub 3 @@ -167,11 +173,8 @@ package require http ### Binding initializations -if {$urllog_search != 0} { - bind pub - !urlfind urllog_pub_urlfind - bind msg - !urlfind urllog_msg_urlfind -} - +bind pub - !urlfind urllog_pub_urlfind +bind msg - !urlfind urllog_msg_urlfind bind pubm - *.* urllog_checkmsg bind topc - *.* urllog_checkmsg @@ -210,10 +213,6 @@ putlog " (Verbose mode enabled)" } -if {$urllog_search != 0} { - putlog " (Search commands enabled)" -} - #------------------------------------------------------------------------- ### Utility functions proc urllog_log {arg} { @@ -603,17 +602,27 @@ #------------------------------------------------------------------------- + + proc urllog_checkmsg {unick uhost uhand uchan utext} { + global urllog_log_channels + ### Check the nick if {$unick == "*"} { urllog_log "urllog_checkmsg: nick was wc, this should not happen." return 0 } - ### Do the URL checking - foreach str [split $utext " "] { - if {[regexp "(ftp|http|https)://|www\..+|ftp\..*" $str]} { - urllog_checkurl $str $unick $uhost $uchan + ### Check the channel + foreach akey [split $urllog_log_channels] { + if {[string match $akey $uchan]} { + ### Do the URL checking + foreach str [split $utext " "] { + if {[regexp "(ftp|http|https)://|www\..+|ftp\..*" $str]} { + urllog_checkurl $str $unick $uhost $uchan + } + } + return 0 } } @@ -686,7 +695,13 @@ #------------------------------------------------------------------------- ### Finding binded functions proc urllog_pub_urlfind {unick uhost uhand uchan utext} { - urllog_find $unick $uhand $uchan $utext 1 + global urllog_search_channels + + foreach akey [split $urllog_search_channels ";"] { + if {[string match $akey $uchan]} { + return [urllog_find $unick $uhand $uchan $utext 1] + } + } return 0 }