# # News System v4 for eggdrop 1.1 # by Ernst 16/11/97 # # Read the README file first, please. # # All configuration is done in news4.conf! You don't need to edit anything in # this file (news4.tcl), unless you want to! # - some useful functions ----------------------------------------------------- if {[info commands isinteger] == ""} { proc isinteger {arg} { if {[string length $arg] == 0} {return 0} set ctr 0 while {$ctr < [string length $arg]} { if {![string match \[0-9\] [string index $arg $ctr]]} {return 0} set ctr [expr $ctr + 1] } return 1 } } if {[info commands hostmask] != ""} { # Streak's maskhost procedure loaded, so use it (hostmask.tcl) proc newsmaskhost { ident } { hostmask $ident } } { # Nope, so use eggdrops internal proc newsmaskhost { ident } { maskhost $ident } } # - read the configuration file ----------------------------------------------- # process each news configuration entry proc news { args } { set args [string tolower $args] global news set chan [string tolower [lindex $args 0]] if {([string index $chan 0] != "#") && ([string index $chan 0] != "&")} { set chan "#$chan" } if {![validchan $chan]} { putlog "erreur news config: le canal $chan n'est pas sous ma surveillance" return 0 } # Create a fresh configuration item for this channel with default values catch { unset news($chan) } lappend news($chan) "[string range $chan 1 end].news" lappend news($chan) "1" lappend news($chan) "0" lappend news($chan) "users" lappend news($chan) "0" lappend news($chan) "0" set config [lindex $args 1] # Parse configuration options, changing the defaults for {set i 0} {$i < [llength $config]} {incr i} { switch [string tolower [lindex $config $i]] { "newsfile" { incr i set news($chan) "[lreplace $news($chan) 0 0 [lindex $config $i]]" } "openread" { incr i if {[lindex $config $i] != 0 && [lindex $config $i] != 1} { putlog "news $chan config warning: Only values 1 or 0 allowed for openread" } { set news($chan) "[lreplace $news($chan) 1 1 [lindex $config $i]]" } } "noticeonjoin" { incr i if {[lindex $config $i] != 0 && [lindex $config $i] != 1} { putlog "news $chan config warning: Only values 1 or 0 allowed for noticeonjoin" } { set news($chan) "[lreplace $news($chan) 2 2 [lindex $config $i]]" } } "allowwrite" { incr i set chosen [string tolower [lindex $config $i]] if {$chosen != "all" && $chosen != "users" && $chosen != "flag"} { putlog "news $chan config warning: Only values 'all', 'users' or 'flag X' allowed for allowwrite" } { if {$chosen == "flag"} { incr i set flag [lindex $config $i] set news($chan) [lreplace $news($chan) 3 3 "flag [lindex $config $i]"] } { set news($chan) "[lreplace $news($chan) 3 3 [lindex $config $i]]" } } } "expiredays" { incr i if {![isinteger [lindex $config $i]]} { putlog "news $chan config warning: expiredays must be integer but is [lindex $config $i]" } { set news($chan) "[lreplace $news($chan) 4 4 [lindex $config $i]]" } } "maxnews" { incr i if {![isinteger [lindex $config $i]]} { putlog "news $chan config warning: maxmsgs must be integer but is [lindex $config $i]" } { set news($chan) "[lreplace $news($chan) 5 5 [lindex $config $i]]" } } default { putlog "news $chan config warning: unknown news parameter: [lindex $config $i]" } } } if {![file exists [lindex $news($chan) 0]]} { if {[catch {set temp [open [lindex $news($chan) 0] a+]}]} { putlog "news $chan config error: Could not write to [lindex $news($chan) 0] file." unset news($chan) } { close $temp } } } set newsconf "[file dirname [info script]]/news.conf" if {![file exist $newsconf]} { putlog "news warning: Configuration file $newsconf not found" } { # Wait 1 sec, for the dynamic channel configuration to be loaded utimer 1 "news_loadconfig $newsconf" } unset newsconf # This tries to copy the news help files to eggdrops 1.3 help directory proc news_copyhelp { } { global help-path set has_dcc 0 set has_msg 0 if {${help-path} == ""} { return 0 } set news_dcchelp "[file dirname [info script]]/news.help" set news_msghelp "[file dirname [info script]]/news.help.msg" if {![file exist ${help-path}/news.help]} { if {[file exist $news_dcchelp]} { if {[catch {exec /bin/cp $news_dcchelp ${help-path}/news.help}]} { return 0 } { putlog "news4: copied $news_dcchelp to the DCC help system" set has_dcc 1 } } } { set has_dcc 1 } if {![file exist ${help-path}/msg/news.help]} { if {[file exist $news_msghelp]} { if {[catch {exec /bin/cp $news_msghelp ${help-path}/msg/news.help}]} { return 0 } { putlog "news4: copied $news_msghelp to the MSG help system" set has_msg 1 } } } { set has_msg 1 } if {$has_msg || $has_dcc} { loadhelp news.help putlog "news4: help loaded... Help with '.help news'" } } set news_ignore_strangers 1 proc news_loadconfig { file } { global news news_ncount news_newnews news_lastseen news_biggest_ts source $file foreach chan [array names news] { set news_ncount($chan) -1 set news_newnews($chan) 0 set news_lastseen($chan) 0 set news_biggest_ts($chan) 0 news_count $chan } if {[array names news] != ""} { foreach chan [array names news] { putlog "news configuration for $chan loaded: $news_ncount($chan) news" } } { set news "" } } # - here comes the script ----------------------------------------------------- # Is there any news? proc news_thereisnews { chan } { global news if {[news_count $chan] == 0} { return 0 } else { return 1 } } # How many news items are there? The first time this is called, it will # read through the file and set the value of news_ncount. In future, the # value of the variable will be used, rather than reading the file each time. # Also updates the news_biggest_ts proc news_count { chan } { global news news_ncount news_biggest_ts set chan [string tolower $chan] # only ever go through reading the file once -- the first time it's called if {$news_ncount($chan) == -1} { set news_ncount($chan) 0 set fd [open [lindex $news($chan) 0] r] while {![eof $fd]} { set inp [gets $fd] if {[eof $fd]} {break} if {[string trim $inp " "] == ""} {continue} if {[lindex $inp 1] > $news_biggest_ts($chan)} { set news_biggest_ts($chan) [lindex $inp 1] } incr news_ncount($chan) } close $fd } return $news_ncount($chan) } # Internal procedure that, given a users handle, tells how many news items # there are in the news file that they haven't read proc news_unread { hand chan } { global news set chan [string tolower $chan] set unread 0 set user_ts [news_get_ts $hand $chan] set fd [open [lindex $news($chan) 0] r] while {![eof $fd]} { set inp [gets $fd] if {[eof $fd]} {break} if {[string trim $inp " "] == ""} {continue} if {[lindex $inp 1] > $user_ts} { incr unread } } close $fd return $unread } # Internal procedure to print out news from the file, since it's done more # than once. 'item' should = 0 if all items are to be printed, or a single # number to print a specific item. If the timestamp is non-zero, only news # items more recent than this timestamp are printed. proc news_print { nick idx item timestamp chan } { global news set chan [string tolower $chan] set next 1 set fd [open [lindex $news($chan) 0] r] while {![eof $fd]} { set inp [gets $fd] if {[eof $fd]} {break} if {[string trim $inp " "] == ""} {continue} # timestamp == 0 to show all items if {[lindex $inp 1] > $timestamp} { set who [lindex $inp 0] set date [string range [lrange [ctime [lindex $inp 1]] 1 3] 0 11] set msg [lrange $inp 2 end] if {$idx == 0} { putnotc $nick [format "%d. \[%s\] \(%s\) %s" $next $who $date $msg] } { putdcc $idx [format "%d. \[%s\] \(%s\) %s" $next $who $date $msg] } } incr next } close $fd return 1 } # Get a users "last read" timestamp from the userfile (uses the xtra field) proc news_get_ts { hand chan } { set have_ts [getuser $hand XTRA "news$chan"] scan $have_ts "%d" have_ts if {$have_ts > 0} { return $have_ts } else { return 0 } } # Set a users "last read" timestamp in the userfile proc news_set_ts {hand new_ts chan} { setuser $hand XTRA "news$chan" $new_ts return } # Add a news item proc news_add { nickidx hostdcc hand chan arg } { set chan [string tolower $chan] # nickidx = irc nickname of poster or idx if it was via dcc # hostdcc = uhost if from irc or "dcc" if via dcc # hand = user handle which will show up in newsfile global news botnick news_ncount news_newnews news_biggest_ts global news_ignore_strangers set message [lrange $arg 1 end] if {$message == ""} { if {$hostdcc == "dcc"} { putdcc $nickidx "Usage: .news \[#channel\] add \"la nouvelle ...\"" putdcc $nickidx " Ajoute \"la nouvelle ...\" aux nouvelles du canal." } { if {!$news_ignore_strangers || $hand != "*"} { putnotc $nickidx "Usage: /msg $botnick news add \[#canal\] \"la nouvelle ...\"" putnotc $nickidx " Ajoute \"la nouvelle ...\" aux nouvelles du canal." } } return 0 } # EB 9/7: To support any users to add news, add unknown users to userfile if {$hand == "*"} { set uhost [newsmaskhost $nickidx!$hostdcc] if {![adduser $nickidx $uhost]} { putnotc $nickidx "Je ne peux t'ajouter comme utilisateur. Essai un autre alias.." return 0 } { setcomment $nickidx "[ctime [unixtime]] Ajouté comme fournisseur de news" set hand $nickidx } } putlog "ADDING NEWS TO: [lindex $news($chan) 0]: $hand [unixtime] $message" set fd [open [lindex $news($chan) 0] a] puts $fd [format "%s %s %s" $hand [unixtime] $message] close $fd # Do not just use 'incr' in case news_ncount currently = -1 set news_ncount($chan) [expr [news_count $chan] + 1] set news_newnews($chan) 1 set news_biggest_ts($chan) [unixtime] set nr [news_count $chan] # EB: Added 'how to delete' output for users who send news to wrong channel if {$hostdcc == "dcc"} { if [valididx $nickidx] { putdcc $nickidx "Ajouté aux nouvelles de $chan , Merci!" putdcc $nickidx "Pour effacer votre nouvelle, utiliser .news $chan erase $nr maintenant!" } } { putnotc $nickidx "Ajouté aux nouvelles de $chan , Merci!" putnotc $nickidx "Pour effacer votre nouvelle, utiliser /msg $botnick news $chan erase $nr maintenant!" } news_expire $chan return 0 } # Delete a news item proc news_del {nickidx hostdcc hand chan arg} { global news botnick news_ncount news_ignore_strangers set chan [string tolower $chan] set otherargs [lrange $arg 1 end] if {[scan $otherargs "%d" which] != 1} { if {$hostdcc == "dcc"} { putdcc $nickidx "Usage: .news erase " putdcc $nickidx " Retire la nouvelle du fichier de nouvelles de $chan" } { if {!$news_ignore_strangers || $hand != "*"} { putnotc $nickidx "Usage: /msg $botnick news erase " putnotc $nickidx " Retire la nouvelle du fichier de nouvelles de $chan" } } return 0 } if {[news_count $chan] == 0} { if {$hostdcc == "dcc"} { putdcc $nickidx "Il n'y a pas de nouvelle sur $chan à effacer." } { putnotc $nickidx "Il n'y a pas de nouvelle sur $chan à effacer." } return 0 } if {($which < 1) || ($which > [news_count $chan])} { if {$hostdcc == "dcc"} { putdcc $nickidx "Le numéro de la nouvelle doit être entre 1 et [news_count $chan]" } { putnotc $nickidx "Le numéro de la nouvelle doit être entre 1 et [news_count $chan]" } return 0 } # We will copy the entries from the original file to a temp file, except # for the one to be deleted, then rename the temp file to be the original. set next 1 set fd [open [lindex $news($chan) 0] r] set newfd [open "[lindex $news($chan) 0]~new" w] while {![eof $fd]} { set inp [gets $fd] if {[eof $fd]} {break} if {[string trim $inp " "] == ""} {continue} set who [lindex $inp 0] if {$next == $which} { # Can only delete your own news unless you're a master # EB 4/7: Also allows channel masters to remove everything if {([string tolower $who] != [string tolower $hand]) && (![matchattr $hand m|m $chan])} { if {$hostdcc == "dcc"} { putdcc $nickidx "Vous ne pouvez effacer les nouvelles d'autrui!" } { putnotc $nickidx "Vous ne pouvez effacer les nouvelles d'autrui!" } puts $newfd $inp } else { # delete it -- ie, do not copy it -- just update the counter # Do not use 'incr' just in case it = -1 set news_ncount($chan) [expr [news_count $chan] - 1] } } else { puts $newfd $inp } incr next } close $fd close $newfd exec /bin/mv [lindex $news($chan) 0]~new [lindex $news($chan) 0] if {$hostdcc == "dcc"} { putdcc $nickidx "Effacement de la nouvelle $which du fichier de $chan !" } { putnotc $nickidx "Effacement de la nouvelle $which du fichier de $chan !" } news_expire $chan return 1 } # Read the channel news proc news_read {nickidx hostdcc hand chan arg} { global news botnick news_biggest_ts set chan [string tolower $chan] set otherargs [lrange $arg 1 end] if {[string trim $otherargs] != ""} { set targ [scan $otherargs "%s " textarg] if {[string compare [string tolower $textarg] "all"] == 0} { if {[news_thereisnews $chan]} { if {$hostdcc == "dcc"} { putdcc $nickidx "News de $chan le [date] ..." news_print $hand $nickidx 0 0 $chan putdcc $nickidx "--- fin ---" } { putnotc $nickidx "News de $chan le [date] ..." news_print $nickidx 0 0 0 $chan putnotc $nickidx "--- fin ---" } } { if {$hostdcc == "dcc"} { putdcc $nickidx "Désolé, il n'y a pas de nouvelles pour $chan!" } { putnotc $nickidx "Désolé, il n'y a pas de nouvelles pour $chan!" } } return 1 } set havearg [scan $otherargs "%d" which] if {$havearg} { if {($which < 1) || ($which > [news_count $chan])} { if {$hostdcc == "dcc"} { putdcc $nickidx "Le numéro de la nouvelle doit être entre 1 et [news_count $chan]" } { putnotc $nickidx "Le numéro de la nouvelle doit être entre 1 et [news_count $chan]" } return 0 } else { if {$hostdcc == "dcc"} { news_print $hand $nickidx $which 0 $chan } { news_print $nickidx 0 $which 0 $chan } return 1 } } } # By the time we are here, it must have no arguments - display only new ones! if {[news_thereisnews $chan]} { set user_ts [news_get_ts $hand $chan] if {$user_ts >= $news_biggest_ts($chan)} { if {$hostdcc == "dcc"} { putdcc $nickidx "Désolé, il n'y a pas de nouvelles sur $chan!" putdcc $nickidx "Pour lire toutes les nouvelles sur $chan, utiliser .news read all" } { putnotc $nickidx "Désolé, il n'y a pas de nouvelles sur $chan!" putnotc $nickidx "Pour lire toutes les nouvelles sur $chan, utiliser /msg $botnick news read all" } } else { if {$hostdcc == "dcc"} { putdcc $nickidx "Nouvelles news pour $hand sur $chan le [date] ..." news_print $hand $nickidx 0 $user_ts $chan putdcc $nickidx "--- fin ---" } { if {$hand == "*"} { set nickhand $nickidx } { set nickhand $hand } putnotc $nickidx "Nouvelles news pour $hand sur $chan le [date] ..." news_print $nickidx 0 0 $user_ts $chan putnotc $nickidx "--- fin ---" } news_set_ts $hand $news_biggest_ts($chan) $chan } } else { if {$hostdcc == "dcc"} { putdcc $nickidx "Désolé, il n'y a pas de nouvelles news sur $chan!" } { putnotc $nickidx "Désolé, il n'y a pas de nouvelles news sur $chan!" } } if {$hostdcc == "dcc"} { putdcc $nickidx "Pour de l'aide sur les commandes des news, utiliser .news help" } { putnotc $nickidx "Pour de l'aide sur les commandes des news, utiliser /msg $botnick news help" } return 1 } # Reset the counter associated with the news file. proc news_reset {nickidx hostdcc hand chan} { global news_ncount news_biggest_ts news_ignore_strangers set chan [string tolower $chan] if {![matchattr $hand m|m $chan]} { if {$hostdcc == "dcc"} { putdcc $nickidx "Vous n'avez pas l'autorisation de resetter les nouvelles de $chan." } { if {!$news_ignore_strangers || $hand != "*"} { putnotc $nickidx "Vous n'avez pas l'autorisation de resetter les nouvelles de $chan." } } return 0 } # Just reset the counter, don't touch the file set news_ncount($chan) -1 set news_biggest_ts($chan) 0 if {$hostdcc == "dcc"} { putdcc $nickidx "OK, news de $chan resettées." } { putnotc $nickidx "OK, news de $chan resettées." } return 1 } # Erase all entries in the news file proc news_clear {nickidx hostdcc hand chan} { global news news_ncount news_newnews news_ignore_strangers set chan [string tolower $chan] if {![matchattr $hand m|m $chan]} { if {$hostdcc == "dcc"} { putdcc $nickidx "Vous n'avez pas l'autorisation d'effacer le fichier de nouvelles de $chan ." } { if {!$news_ignore_strangers || $hand != "*"} { putnotc $nickidx "Vous n'avez pas l'autorisation d'effacer le fichier de nouvelles de $chan ." } } return 0 } set fd [open [lindex $news($chan) 0] w] puts $fd " " close $fd set news_ncount($chan) -1 set news_newnews($chan) 0 if {$hostdcc == "dcc"} { putdcc $nickidx "Ok, le fichier de news de $chan a été effacé!" } { putnotc $nickidx "Ok, le fichier de news de $chan a été effacé!" } return 1 } # Check what news there is to be read proc news_check {nickidx hostdcc hand chan join} { global botnick news_ignore_strangers set chan [string tolower $chan] set unread [news_unread $hand $chan] if {$unread} { if {$hostdcc == "dcc"} { putdcc $nickidx "Il y a des nouvelles news sur $chan ($unread non-lues sur [news_count $chan] au total). .news $chan read" } { putnotc $nickidx "Il y a des nouvelles news sur $chan ($unread non-lues sur [news_count $chan] au total). .news $chan read (dans AideBot)" } } { if {!$join} { if {$hostdcc == "dcc"} { putdcc $nickidx "Il n'y a pas de nouvelle news sur $chan." } { if {!$news_ignore_strangers || $hand != "*"} { putnotc $nickidx "Il n'y a pas de nouvelle news sur $chan." } } } } return 1 } # Sets default users news channel to 'chan'. If user is not a valid user # creates a new entry for him using current user/host ident. proc news_default {nickidx hostdcc hand chan} { global botnick news set chan [string tolower $chan] if {$chan == ""} { set defchan [getuser $hand XTRA newsdefault] if {$defchan == ""} { if {$hostdcc == "dcc"} { putdcc $nickidx "Vous n'avez pas de canal de news par défaut. Pour en choisir un, utiliser .news default #canal" } { putnotc $nickidx "Vous n'avez pas de canal de news par défaut. Pour en choisir un, utiliser /msg $botnick news default #canal" } } { if {$hostdcc == "dcc"} { putdcc $nickidx "Votre type de news par défaut est $defchan." putdcc $nickidx "Utiliser .news default none pour effacer le canal de nouvelles par défaut." } { putnotc $nickidx "Votre canal de news par défaut est $defchan." putnotc $nickidx "Utiliser /msg $botnick news default none pour effacer le canal de nouvelles par défaut." } } return 0 } if {[lsearch -exact [string tolower [concat [array names news] "none"]] [string tolower $chan]] == -1} { if {$hostdcc == "dcc"} { putdcc $nickidx "Je n'ai pas de nouvelles pour $chan." } { putnotc $nickidx "Je n'ai pas de nouvelles pour $chan." } return 0 } if {$hand == "*"} { set uhost [newsmaskhost $nickidx!$hostdcc] if {![adduser $nickidx $uhost]} { putnotc $nickidx "Je ne peux pas t'ajouter comme utilisateur, essaie un autre alias." return 0 } { setcomment $nickidx "[ctime [unixtime]] Ajouter pour les nouvelles par défaut." set hand $nickidx } } if {$chan == "none"} { setuser $hand XTRA newsdefault "" if {$hostdcc == "dcc"} { putdcc $nickidx "Canal de nouvelles par défaut effacé!" } { putnotc $nickidx "Canal de nouvelles par défaut effacé!" } } { setuser $hand XTRA newsdefault $chan if {$hostdcc == "dcc"} { putdcc $nickidx "Canal de nouvelles par défaut mis à $chan!" } { putnotc $nickidx "Canal de nouvelles par défaut mis à $chan!" } } return 1 } # Expire old news according to date and number of messages in news file proc news_expire { chan } { global news botnick news_ncount set chan [string tolower $chan] if {[lindex $news($chan) 4] == 0} { set oldsecs 0 } { set oldsecs [expr [unixtime] - ([lindex $news($chan) 4] * 86400)] } # Two step expiration: 1) read and copy only news "in time" to a new file # 2) read this new file and copy only "max number" news. set news_ncount($chan) 0 set fd [open [lindex $news($chan) 0] r] set newfd [open "[lindex $news($chan) 0]~new" w] while {![eof $fd]} { set inp [gets $fd] if {[eof $fd]} { break } if {[string trim $inp " "] == ""} { continue } set time [lindex $inp 1] if {$time > $oldsecs} { incr news_ncount($chan) puts $newfd $inp # else, delete it -- ie, do not copy it } } close $fd close $newfd # Make some calculations to see from which news on should I copy set maxnews [lindex $news($chan) 5] if {$maxnews == 0} { set skip 0 } { set skip [expr $news_ncount($chan) - $maxnews] } set next 0 set fd [open [lindex $news($chan) 0]~new r] set newfd [open "[lindex $news($chan) 0]" w] set news_ncount($chan) 0 while {![eof $fd]} { set inp [gets $fd] incr next if {[eof $fd]} {break} if {[string trim $inp " "] == ""} {continue} if {$next <= $skip} {continue} incr news_ncount($chan) puts $newfd $inp } close $fd close $newfd exec /bin/rm [lindex $news($chan) 0]~new return 0 } # When joining the channel or partyline, check for new news #bind join - * join:news_check CHANGÉ ICI POUR N'INCLURE QUE LES MEMBRES AUTORISÉS ************ #bind chon - * chon:news_check #bind join p * join:news_check #bind chon p * chon:news_check proc join:news_check { nick uhost hand chan } { global news botnick set chan [string tolower $chan] set chan [string tolower $chan] if {$hand != "*"} { setlaston $hand $chan } if {![info exist news($chan)]} { return 0 } # Don't annoy other bots if {[matchattr $hand b]} { return 0 } if {(![lindex $news($chan) 1] && $hand == "*") || $nick == $botnick} { return 0 } if {[lindex $news($chan) 2]} { news_check $nick $uhost $hand $chan 1 } } proc chon:news_check { hand idx } { global news set chan &general if {$chan == "*"} { return 0 } if {![info exist news($chan)]} { return 0 } if {[lindex $news($chan) 2]} { news_check $idx "dcc" $hand $chan 0 } } # Display some help proc news_help {nickidx hostdcc hand chan} { global botnick set chan [string tolower $chan] if {$hostdcc == "dcc"} { putdcc $nickidx "Usage: .news \[#canal\] read \[#\]" putdcc $nickidx " .news \[#canal\] read all" putdcc $nickidx " .news \[#canal\] check" if {[matchattr $hand o|o $chan]} { putdcc $nickidx " .news \[#canal\] add " putdcc $nickidx " .news \[#canal\] erase " } if {[matchattr $hand m|m $chan]} { putdcc $nickidx " .news \[#canal\] reset \[#channel\]" putdcc $nickidx " .news \[#canal\] clear \[#channel\]" } putdcc $nickidx " .news default #canal" } { putnotc $nickidx "/msg $botnick news \[#canal\] " putnotc $nickidx " peu être ADD, ERASE , CHECK, READ, READ ALL" if {[matchattr $hand m|m $chan]} { putnotc $nickidx " RESET, CLEAR" } putnotc $nickidx "/msg $botnick news default #canal pour choisir votre canal de nouvelles par défaut." } return 0 } # Make a reasonable guess of which channel the user wants to process news for # This is used when no channel was specified proc get_news_chan {nick hand idx arg} { global news # Is there any default channel saved? set defchan "&general" if {([string index [lindex $arg 0] 0] == "#") || ([string index [lindex $arg 0] 0] == "&")} { # User has specified a channel set chan [lindex $arg 0] } elseif {$defchan != ""} { # User has a default news channel... set chan $defchan } { if {$idx == 0} { # Find channel user joined last set high 0 # Which is the channel the user last joined? foreach newschan [array names news] { if {[onchan $nick $newschan]} { if {[getchanjoin $nick $newschan] > $high} { set high [getchanjoin $nick $newschan] set chan $newschan } } } # Is the LASTON channel also a NEWS channel? Yes? Use it... if {![info exist chan]} { set lastonchan [string tolower [lindex [getuser $hand LASTON] 1]] if {[info exist $news($lastonchan)]} { set chan $lastonchan } } # Last resort, use first configured news channel # this will *always* work if there is only one news channel if {![info exist chan]} { set chan [lindex [array names news] 0] } } { set conschan [lindex [console $idx] 0] if {$conschan == "*"} { set chan "" } { set chan $conschan } } } return $chan } #bind msg - news msg_news MIS EN COMMENTAIRE POUR ENLEVER LES NOUVELLES PAR MSG # The main binding - does the dispatching of requests proc msg_news { nick uhost hand arg } { global news news_ignore_strangers if {[string tolower [lindex $arg 0]] == "default"} { set chan [string tolower [lindex $arg 1]] return [news_default $nick $uhost $hand $chan] } set chan [get_news_chan $nick $hand 0 $arg] if {([string index [lindex $arg 0] 0] == "#") || ([string index [lindex $arg 0] 0] == "&")} { # Remove channel from arg set arg [lreplace $arg 0 0] } if {$chan == ""} { if {!$news_ignore_strangers || $hand != "*"} { putnotc $nick "IL n'y a pas de nouvelle du tout!" } } if {[lsearch -exact [string tolower [array names news]] [string tolower $chan]] == -1} { if {!$news_ignore_strangers || $hand != "*"} { putnotc $nick "Je ne m'occupe pas du canal $chan." } return 0 } switch [string tolower [lindex $arg 0]] { "add" { set pass 0 if {[lindex [lindex $news($chan) 3] 0] == "all"} { set pass 1 } elseif {[lindex [lindex $news($chan) 3] 0] == "users" && $hand != "*"} { set pass 1 } elseif {[lindex [lindex $news($chan) 3] 0] == "flag"} { set whichflag [lindex [lindex $news($chan) 3] 1] if {[matchattr $hand $whichflag|$whichflag $chan]} { set pass 1 } } if {$pass} { set r [news_add $nick $uhost $hand $chan $arg] } { if {$hand != "*" || !$news_ignore_strangers} { putnotc $nick "Tu ne peux ajouter de nouvelles sur $chan , désolé!" } set r 0 } } "del" { set r [news_del $nick $uhost $hand $chan $arg] } "delete" { set r [news_del $nick $uhost $hand $chan $arg] } "erase" { set r [news_del $nick $uhost $hand $chan $arg] } "read" { if {![lindex $news($chan) 1] || $hand != "*"} { set r [news_read $nick $uhost $hand $chan $arg] } { if {$hand != "*" || !$news_ignore_strangers} { putnotc $nick "You are not allowed to read $chan news, sorry!" } set r 0 } } "check" { set r [news_check $nick $uhost $hand $chan 0] } "reset" { set r [news_reset $nick $uhost $hand $chan] } "clear" { set r [news_clear $nick $uhost $hand $chan] } default { set r [news_help $nick $uhost $hand $chan] } } return $r } bind dcc - news dcc_news # main dcc binding proc dcc_news {hand idx arg} { global news if {[string tolower [lindex $arg 0]] == "default"} { set chan [string tolower [lindex $arg 1]] return [news_default $idx "dcc" $hand $chan] } set chan [get_news_chan "" $hand $idx $arg] if {([string index [lindex $arg 0] 0] == "#") || ([string index [lindex $arg 0] 0] == "&")} { # Remove channel from arg set arg [lreplace $arg 0 0] } if {[lsearch -exact [string tolower [array names news]] [string tolower $chan]] == -1} { putdcc $idx "Je n'ai pas de nouvelles pour $chan." putdcc $idx "Essaie de changer ta .console ." return 0 } switch [string tolower [lindex $arg 0]] { "add" { set pass 0 if {[lindex [lindex $news($chan) 3] 0] == "flag"} { set whichflag [lindex [lindex $news($chan) 3] 1] if {([matchattr $hand $whichflag|$whichflag $chan])||([matchattr $hand $whichflag])} { set pass 1 } } { set pass 1 } if {$pass} { set r [news_add $idx dcc $hand $chan $arg] if {[string tolower $chan] == "&projets"} { setuser $hand xtra dernierenewsprojets [unixtime] } } { putdcc $idx "Tu ne peux pas ajouter de nouvelle sur $chan , désolé" set r 0 } } "del" { set r [news_del $idx dcc $hand $chan $arg] } "delete" { set r [news_del $idx dcc $hand $chan $arg] } "erase" { set r [news_del $idx dcc $hand $chan $arg] } "read" { set r [news_read $idx dcc $hand $chan $arg] } "check" { set r [news_check $idx dcc $hand $chan 0] } "reset" { set r [news_reset $idx dcc $hand $chan] } "clear" { set r [news_clear $idx dcc $hand $chan] } default { set r [news_help $idx dcc $hand $chan] } } return $r } # news_copyhelp RETIRÉ POUR ÉVITER LA COPIE DU FICHIER D'AIDE PAR MSG