All pastes #795016 Raw Edit

Untitled

public text v1 · immutable
#795016 ·published 2007-11-23 16:46 UTC
rendered paste body
bind pub - !lastlines pub_lastlines
set quotefile "/var/www/logs/"

proc pub_lastlines {nick uhost hand chan rest} {
global quotefile
set query [string tolower [lindex $rest 0]]
set search "*\[??:??\] <$query>*"
	if {$query == ""} {
	putserv "PRIVMSG $chan :Usage: !lastlines <nick>"
	} else {
	set file "$quotefile$chan.log"
	set fl [open $file r]
	set data [read $fl]
	close $fl
	set lines [split "$data" \n]
	set searchresults [lsearch -inline $lines $search]
		if {$searchresults == ""} {
		putserv "PRIVMSG $chan :No results found for $search in $file"
		putserv "PRIVMSG $chan :[lindex $data 1]"
		} else {
			if {[string length $searchresults] < 150} {
			putserv "PRIVMSG $chan :last lines by $query"
			putserv "PRIVMSG $chan :$searchresults"
			} else {
			putserv "PRIVMSG $chan :last lines by $query"
			putserv "PRIVMSG $chan :$searchresults"
			}
		}
	}
}