egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

include nickname on quotation

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
fredvil
Voice


Joined: 01 Dec 2005
Posts: 21

PostPosted: Tue Oct 31, 2006 7:35 am    Post subject: include nickname on quotation Reply with quote

hello guys need your help.... i am using a quotebot and u just want to know if it is posible if someone add a quotation, his/her nickname will automatically included on the quotation. this is for us to monitor and trace unwanted post quote... thank you very much in advance.

here is the script:

Code:
# ^-- don't remove this line
#   ___              _       ____        _
#  / _ \ _   _  ___ | |_ ___| __ )  ___ | |_
# | | | | | | |/ _ \| __/ _ \  _ \ / _ \| __|
# | |_| | |_| | (_) | ||  __/ |_) | (_) | |_
#  \__\_\\__,_|\___/ \__\___|____/ \___/ \__|
#                2.0 by Baerchen, August 2001
#              for eggdrop 1.4.x+ & TCL 8.3.3
#                   baerchen@germany-chat.net
#
# Please report bugs. Thanks.
#
# CONFIGURATION
#
# qb(workdir) is the location for the cache files. Leave leading & trailing /'s as is.
set qb(workdir) "/usr/home/blah/eggdrop/scripts/"

# Do you want to use channel-specific quotes? If so, quotes added in channel #a aren't
# available in channel #b and vice versa. If not, all quotes are available everywhere.
# You don't have to decide now, you can en- and disable this feature later as you want.
# 0 = do not, 1 = yes please
set qb(chanspec) 0

# qb(noaddchan) is a list of channels which aren't allowed to add quotes
set qb(noaddchan) ""

# qb(noquotechan) is a list of channels you don't want the bot to quote to
set qb(noquotechan) ""

# qb(max) is the maximum characters a quote is allowed to have.
set qb(max) 999

# Next one will let the bot answer to his nick when mentioned in the channel. Put your bot's
# name within the ** and uncoment the line. Example: bind pubm - *LamestBot* qb:answer
# bind pubm - ** qb:answer

# qb(logactions) defines whether you want to log additions or deletions of quotes
# 0 = do not, 1 = yes please
set qb(logactions) 1

# qb(trigger) is the character that triggers a command.
set qb(trigger) "."

# qb(sendnote) defines whether QuoteBot sends a note to a user when there are
# new quotes available. To disable, set to "". To enable, insert a valid handle
# and make sure the notes module is loaded.
set qb(sendnote) ""

# CODEBASE BELOW

bind pub - ${qb(trigger)}addquote qb:addpub
bind pub - ${qb(trigger)}quote qb:quote
bind pub n|n ${qb(trigger)}delquote qb:delpub
bind pub m|m ${qb(trigger)}talk qb:init
bind dcc - addquote qb:adddcc
bind dcc n delquote qb:deldcc
bind dcc n listquotes qb:listquotes
bind dcc n newquotes qb:newquotes
bind dcc n copyquotes qb:copy
bind dcc n delchanquotes qb:delchan

proc qb:read {} {
 global qb qbl qbt
 set old "$qb(workdir)quotebot.dat"; set new "$qb(workdir)QuoteBot.dat"
 if {[file exists $old]} {
  set fid [open $old r]; gets $fid l; set qb(nextind) 1; set qb(nextcind) 1
  while {![eof $fid]} {
   gets $fid l; if {$l == ""} {continue}
   regsub -all \\\* $l !%08 l; regsub -all \\\? $l !%09 l
   set qbl($qb(nextind)#$qb(nextcind)#quotebot) $l; incr qb(nextind); incr qb(nextcind)
  }
  close $fid; file rename -force $old $old.old; qb:saveqts; set qb(conversion) 1
 }
 if {[file exists $new]} {
  set fid [open $new r]; gets $fid l; if {$l != "0"} {set qb(new) $l}
  while {![eof $fid]} {gets $fid l; if {$l == ""} {continue}; set qbl([lindex $l 0]) [lrange $l 1 end]}
  close $fid
 }
 if {[file exists $qb(workdir)quotebot.cfg]} {
  file rename -force $qb(workdir)quotebot.cfg $qb(workdir)QuoteBot.cfg; set fid [open $qb(workdir)QuoteBot.cfg r]
  while {![eof $fid]} {
   gets $fid l; if {$l == ""} {continue}
   set qbt([lindex $l 0]) "[lindex $l 1] [lindex $l 2] [timer [lindex $l 2] "qb:scheduled [lindex $l 0]"]"
  }
  close $fid
 }
 if {[file exists $qb(workdir)quotebot.log]} {file rename -force $qb(workdir)quotebot.log $qb(workdir)QuoteBot.log}
}

proc qb:saveqts {} {
 global qb qbl
 set fid [open $qb(workdir)QuoteBot.dat w]
 if {$qb(new) == ""} {puts $fid "0"} else {puts $fid $qb(new)}
 foreach e [array names qbl] {set el [split $e #]; puts $fid "$e $qbl($e)"}
 close $fid
}

proc qb:savecfg {} {
 global qb qbt
 set fid [open $qb(workdir)QuoteBot.cfg w]
 foreach e [array names qbt] {puts $fid "$e [lindex $qbt($e) 0] [lindex $qbt($e) 1]"}
 close $fid
}

proc qb:log {input} {
 global qb
 set log "$qb(workdir)QuoteBot.log"
 if {[file exists $log]} {set fid [open $log a]} else {set fid [open $log w]}
 puts $fid "$input"; close $fid
}

proc qb:addpub {n uh h c arg} {
 global qb qbl
 set c [string tolower $c]
 foreach b $qb(noaddchan) {if {[string match -nocase $c $b]} {return}}
 set arg [qb:rs $arg]
 if {[string length $arg] > $qb(max)} {puthelp "NOTICE $n :Quote exceeds $qb(max) characters. Yours has [string length $arg]."; return}
 if {[llength $arg] == 0} {puthelp "NOTICE $n :Usage: ${qb(trigger)}addquote <quote>"; return}
 if {$qb(chanspec)} {
  foreach e [array names qbl] {if {[string match "#[lindex [split $e #] 2]" $c] && [string match -nocase $qbl($e) $arg]} {set index [lindex [split $e #] 1]}}
  } else {
  foreach e [array names qbl] {if {[string match -nocase $qbl($e) $arg]} {set index [lindex [split $e #] 0]}}   
 }
 if {[info exists index]} {puthelp "NOTICE $n :The quote you tried to add already exists (index #$index)."; return}
 qb:findnn $c; set index $qb(nextind)#$qb(nextcind)$c; set qbl($index) $arg; lappend qb(new) $index; qb:saveqts
 if {$qb(chanspec)} {set index $qb(nextcind)} else {set index $qb(nextind)}
 puthelp "NOTICE $n :Added Quote #${index}: \"[qb:dr $arg]\""
 if {[llength $qb(new)] == 1} {
  if {$qb(sendnote) != ""} {
   if {[info commands sendnote] != ""} {
    if {[validuser $qb(sendnote)]} {sendnote QuoteBot $qb(sendnote) "New quotes available. Use .newquotes to list them."}
   }
  }
 }
 if {$qb(logactions)} {qb:log "ADD PUB $n $c (#$index) [qb:dr $arg]"}
}

proc qb:adddcc {h idx arg} {
 global qb qbl
 if {$qb(chanspec)} {
  if {[llength $arg] < 2} {putdcc $idx "Usage: ${qb(trigger)}addquote <channel> <quote>"; return}
  set c [string tolower [lindex $arg 0]]; set arg [lrange [qb:rs $arg] 1 end]
  if {![string match #* $c]} {putdcc $idx "Usage: addquote <channel> <quote>"; return}
  foreach b $qb(noaddchan) {if {[string match -nocase $c $b]} {return}}
  foreach e [array names qbl] {if {[string match "#[lindex [split $e #] 2]" $c] && [string match -nocase $qbl($e) $arg]} {set index [lindex [split $e #] 1]}}
  if {[info exists index]} {putdcc $idx "The quote you tried to add already exists for $c (index #$index)."; return}
  qb:findnn $c; set index $qb(nextind)#$qb(nextcind)$c; set qbl($index) $arg; lappend qb(new) $index; qb:saveqts
  putdcc $idx "Added Quote #$qb(nextcind) for $c: \"[qb:dr $arg]\""
  } else {
  set c #quotebot; set arg [qb:rs $arg]
  if {[string length $arg] > $qb(max)} {putdcc $idx "Quote exceeds $qb(max) characters. Yours has [string length $arg]."; return}
  if {[llength $arg] == 0} {putdcc $idx "Usage: ${qb(trigger)}addquote <quote>"; return}
  foreach e [array names qbl] {if {[string match -nocase $qbl($e) $arg]} {set index [lindex [split $e #] 0]}}
  if {[info exists index]} {putdcc $idx "The quote you tried to add already exists (index #$index)."; return}
  qb:findnn $c; set index $qb(nextind)#$qb(nextcind)$c; set qbl($index) $arg; lappend qb(new) $index; qb:saveqts
  putdcc $idx "Added Quote #$qb(nextind): \"[qb:dr $arg]\""
 }
 if {[llength $qb(new)] == 1} {
  if {$qb(sendnote) != ""} {
   if {[info commands sendnote] != ""} {
    if {[validuser $qb(sendnote)]} {sendnote QuoteBot $qb(sendnote) "New quotes available. Use .newquotes to list them."}
   }
  }
 }
 if {$qb(logactions)} {qb:log "ADD PUB $h $c (#$index) [qb:dr $arg]"}
}

proc qb:newquotes {h idx arg} {
 global qb qbl
 set len [llength $qb(new)]
 putdcc $idx "$len new quote(s) have arrived. There are [array size qbl] quotes in the database."
 if {$len > 0} {
  if {$qb(chanspec)} {
   putdcc $idx "(No.) (Channel: No.) Quote"
   foreach e $qb(new) {set el [split $e #]; putdcc $idx "(#[lindex $el 0]) (#[lindex $el 2]: #[lindex $el 1]) [qb:dr $qbl($e)]"}
   } else {
   putdcc $idx "(No.) Quote"
   foreach e $qb(new) {set el [split $e #]; putdcc $idx "(#[lindex $el 0]) [qb:dr $qbl($e)]"}
  }
  set qb(new) ""; qb:saveqts
 }
}

proc qb:listquotes {h idx arg} {
 global qb qbl
 set argu $arg; set arg [string tolower [qb:rs $arg]]; set list ""
 if {![string match #* $arg]} {
  if {$arg == ""} {set insert ""; foreach e [array names qbl] {lappend list $e}} else {
   set insert "matching \"[qb:dr $argu]\""
   foreach e [array names qbl] {if {[string match -nocase *$arg* $qbl($e)]} {lappend list $e}}
  }
 } else {
  if {$qb(chanspec)} {
   set insert "for channel $argu"
   foreach e [array names qbl] {if {[string match -nocase "#[lindex [split $e #] 2]" $arg]} {lappend list $e}}
   } else {
   set insert "matching \"[qb:dr $argu]\""
   foreach e [array names qbl] {if {[string match -nocase *$arg* $qbl($e)]} {lappend list $e}}
  }
 }
 if {[llength $list] > 0} {
  set nlist ""; foreach e $list {lappend nlist "[lindex [split $e #] 0] $e"}; set list ""
  set nlist [lsort -decreasing -integer -index 0 $nlist]; foreach e $nlist {lappend list [lindex $e 1]}
  putdcc $idx "Found [llength $list] quotes (out of [array size qbl]) $insert, latest first."
  if {$qb(chanspec)} {
   putdcc $idx "(No.) (Channel: No.) Quote"
   foreach e $list {set el [split $e #]; putdcc $idx "(#[lindex $el 0]) (#[lindex $el 2]: #[lindex $el 1]) [qb:dr $qbl($e)]"}
   } else {
   putdcc $idx "(No.) Quote"
   foreach e $list {set el [split $e #]; putdcc $idx "(#[lindex $el 0]) [qb:dr $qbl($e)]"}
  }
 } else {putdcc $idx "Found no matches to your query."}
}

proc qb:quote {n uh h c arg} {
 global qb qbl
 foreach e $qb(noquotechan) {if {[string match -nocase $c $e]} {return}}
 set arg [qb:rs $arg]; regsub -all \\*|\\? $arg "" arg
 if {![info exists qb(${c}results)]} {set qb(${c}results) ""}
 if {![info exists qb(${c}last)]} {set qb(${c}last) ""}
 if {$arg == ""} {puthelp "PRIVMSG $c :[qb:random $c]"; return}
 if {[string is integer $arg]} {
  if {$qb(chanspec)} {
   foreach e [array names qbl] {if {[string match *#$arg$c $e]} {puthelp "PRIVMSG $c :(#[lindex [split $e #] 1]) [qb:dr $qbl($e)]"; return}}
   } else {
   foreach e [array names qbl] {if {[string match ${arg}#* $e]} {puthelp "PRIVMSG $c :(#[lindex [split $e #] 0]) [qb:dr $qbl($e)]"; return}}
  }
  puthelp "NOTICE $n :Can't find index $arg"; return
 }
 if {[string match -nocase $arg $qb(${c}last)]} {
  set e [lindex $qb(${c}results) 0]; set qb(${c}results) [lreplace $qb(${c}results) 0 0]; set len [llength $qb(${c}results)]
  if {$qb(chanspec)} {set el [lindex [split $e #] 1]} else {set el [lindex [split $e #] 0]}
  puthelp "PRIVMSG $c :(#$el) [qb:dr $qbl($e)] ($len left)"
  if {$len == 0} {unset qb(${c}results); set qb(${c}last) ""; return} else {set qb(${c}last) $arg}
  return
 }
 set qb(${c}results) ""
 if {$qb(chanspec)} {
  foreach e [array names qbl] {
   if {[string match "#[lindex [split $e #] 2]" $c] && [string match -nocase *$arg* $qbl($e)]} {lappend qb(${c}results) $e}}
  } else {
   foreach e [array names qbl] {if {[string match -nocase *$arg* $qbl($e)]} {lappend qb(${c}results) $e}}
 }
 set len [llength $qb(${c}results)]
 if {$len == 0} {puthelp "NOTICE $n :Found no quotes matching \"[qb:dr $arg]\""; unset qb(${c}results); set qb(${c}last) ""; return}
 set qb(${c}results) [lsort -decreasing $qb(${c}results)]; set e [lindex $qb(${c}results) 0]
 if {$qb(chanspec)} {set el [lindex [split $e #] 1]} else {set el [lindex [split $e #] 0]}
 puthelp "PRIVMSG $c :(#$el) [qb:dr $qbl($e)] ($len match(es), latest first)"
 set qb(${c}results) [lreplace $qb(${c}results) 0 0]; set qb(${c}last) $arg
}

proc qb:answer {n uh h c a} {
 global qb qbl
 foreach e $qb(noquotechan) {if {[string match -nocase $e $c]} {return}}
 puthelp "PRIVMSG $c :[qb:random $c]"
}

proc qb:init {n uh h c arg} {
 global qb qbt
 set ch [string tolower $c]; set switch [string tolower [lindex [split $arg] 0]]; set rate [lindex $arg 1]
 if {($switch != "on") && ($switch != "off")} {puthelp "NOTICE $n :Usage: talk <on|off> \[minutes\]"; return}
 if {$rate == ""} {set rate 30} elseif {![string is integer $rate]} {puthelp "NOTICE $n :Use an integer instead of $rate"; return}
 switch $switch {
  "on" {
   if {([info exists qbt($ch)]) && ([lindex $qbt($ch) 0] == "on")} {
    killtimer [lindex $qbt($ch) 2]
    set qbt($ch) "on $rate [timer $rate "qb:scheduled $ch"]"
   } else {set qbt($ch) "on $rate [timer $rate "qb:scheduled $ch"]"}
   puthelp "PRIVMSG $c :Enabled quoting for $c with $rate minutes intervall"
  }
  "off" {
   if {([info exists qbt($ch)]) && ([lindex $qbt($ch) 0] == "on")} {
    killtimer [lindex $qbt($ch) 2]; unset qbt($ch)
    puthelp "PRIVMSG $c :Disabled quoting for $c"
   } else {puthelp "NOTICE $n :Quoting was not enabled for $c"}
  }
 } 
 qb:savecfg
}

proc qb:scheduled {c} {
 global qb qbl qbt
 puthelp "PRIVMSG $c :[qb:random $c]"
 set rate [lindex $qbt($c) 1]; set qbt($c) "on $rate [timer $rate "qb:scheduled $c"]"
}

proc qb:delpub {n uh h c arg} {
 global qb qbl
 set c [string tolower $c]; regsub -all \\*|\\? $arg "" arg; set arg [split [qb:rs $arg]]; set del ""; set nodel ""; set i 0
 if {[llength $arg] == 0} {puthelp "NOTICE $n :Usage: ${qb(trigger)}delquote <index ?index index ..?|mask>"; return}
 if {[string is integer [lindex $arg 0]]} {
  if {$qb(chanspec)} {
   foreach e $arg {
    set f 0
    foreach el [array names qbl] {
     set ele [split $el #]
     if {[string match "#[lindex $ele 2]" $c] && [string match -nocase [lindex $ele 1] $e]} {unset qbl($el); lappend del $e; set f 1; qb:delnew [lindex $ele 0]}
    }
   if {!$f} {lappend nodel $e}
   }
  } else {
   foreach e $arg {
    set f 0
    foreach el [array names qbl] {
     set ele [lindex [split $el #] 0]
     if {[string match -nocase $ele $e]} {unset qbl($el); lappend del $e; set f 1; qb:delnew $ele}
    }
   if {!$f} {lappend nodel $e}
   }
  }
  qb:saveqts
  if {$del != ""} {puthelp "NOTICE $n :Deleted indices [join $del ", "]"; if {$qb(logactions)} {qb:log "DEL PUB $n $c [qb:dr $arg]"}}
  if {$nodel != ""} {puthelp "NOTICE $n :I can't find indices [join $nodel ", "]"}
  return
 }
 set arg [join $arg]
 if {$qb(chanspec)} {
  foreach e [array names qbl] {
   if {[string match "#[lindex [split $e #] 2]" $c] && [string match -nocase *$arg* $qbl($e)]} {unset qbl($e); incr i; qb:delnew [lindex [split $e #] 0]}
  }
 } else {
  foreach e [array names qbl] {
   if {[string match -nocase *$qbl($e)* $arg]} {unset qbl($e); incr i; qb:delnew [lindex [split $e #] 0]}
  } 
 }
 if {!$i} {puthelp "NOTICE $n :Can't find a quote matching \"[qb:dr $arg]\""; return} else {
  puthelp "NOTICE $n :Removed $i quote(s) matching \"[qb:dr $arg]\""; qb:saveqts
  if {$qb(logactions)} {qb:log "DEL PUB $n $c [qb:dr $arg]"}
 }
}

proc qb:deldcc {h idx arg} {
 global qb qbl
 set del ""; set nodel ""; set i 0; regsub -all \\*|\\? $arg "" arg
 if {$qb(chanspec)} {
  if {[llength $arg] < 2} {putdcc $idx "Usage: ${qb(trigger)}delquote <channel> <index ?index index ..?|mask>"; return}
  set c [string tolower [lindex $arg 0]]; set arg [lrange [qb:rs $arg] 1 end]
  if {![string match #* $c]} {putdcc $idx "Usage: ${qb(trigger)}delquote <channel> <index ?index index ..?|mask>"; return}
  if {[string is integer [lindex $arg 0]]} {
   foreach e $arg {
    set f 0
    foreach el [array names qbl] {
     set ele [split $el #]
     if {[string match "#[lindex $ele 2]" $c] && [string match -nocase [lindex $ele 1] $e]} {unset qbl($el); lappend del $e; set f 1; qb:delnew [lindex $ele 0]}
    }
    if {!$f} {lappend nodel $e}
   }
   if {$del != ""} {putdcc $idx "Deleted indices [join $del ", "] for $c"; if {$qb(logactions)} {qb:log "DEL DCC $h $c [qb:dr $arg]"}}
   if {$nodel != ""} {putdcc $idx "I can't find indices [join $nodel ", "] for $c"}
   qb:saveqts; return
  }
  foreach e [array names qbl] {
   if {[string match "#[lindex [split $e #] 2]" $c] && [string match -nocase *$arg* $qbl($e)]} {unset qbl($e); incr i; qb:delnew [lindex [split $e #] 0]}
  }
  if {!$i} {putdcc $idx "Can't find a quote for $c matching \"[qb:dr $arg]\""; return} else {
   putdcc $idx "Removed $i quote(s) for $c matching \"[qb:dr $arg]\""; qb:saveqts
  }
  if {$qb(logactions)} {qb:log "DEL DCC $h $c [qb:dr $arg]"}
 } else {
  if {[llength $arg] == 0} {putdcc $idx "Usage: ${qb(trigger)}delquote <index ?index index ..?|mask>"; return}
  set arg [qb:rs $arg]
  if {[string is integer [lindex $arg 0]]} {
   foreach e $arg {
    set f 0
    foreach el [array names qbl] {
     set ele [lindex [split $el #] 0]
     if {[string match -nocase $ele $e]} {unset qbl($el); lappend del $e; set f 1; qb:delnew $ele}
    }
    if {!$f} {lappend nodel $e}
   }
   if {$del != ""} {putdcc $idx "Deleted indices [join $del ", "]"; if {$qb(logactions)} {qb:log "DEL DCC $h [qb:dr $arg]"}}
   if {$nodel != ""} {putdcc $idx "I can't find indices [join $nodel ", "]"}
   qb:saveqts; return
  }
  foreach e [array names qbl] {if {[string match -nocase *$qbl($e)* $arg]} {unset qbl($e); incr i; qb:delnew [lindex [split $e #] 0]}} 
  if {!$i} {putdcc $idx "Can't find a quote matching \"[qb:dr $arg]\""; return} else {
   putdcc $idx "Removed $i quote(s) matching \"[qb:dr $arg]\""; qb:saveqts
   if {$qb(logactions)} {qb:log "DEL DCC $h [qb:dr $arg]"}
  }
 }
}

proc qb:copy {h idx arg} {
 global qb qbl
 if {!$qb(chanspec)} {putdcc $idx "Command not available (script option \"channel specific quotes\" is disabled)"; return}
 set fromc [string tolower [lindex $arg 0]]; set toc [string tolower [lindex $arg 1]]
 if {$fromc == $toc || [llength $arg] != 2} {putdcc $idx "Usage: copyquotes <fromchannel> <tochannel>"; return}
 qb:findnn $toc; set l ""
 foreach e [array names qbl] {if {[string match "#[lindex [split $e #] 2]" $fromc]} {lappend l $qbl($e)}}
 if {[llength $l] == 0} {putdcc $idx "Can't find any quotes for $fromc."; return}
 foreach e $l {set qbl($qb(nextind)#$qb(nextcind)$toc) $e; incr qb(nextind); incr qb(nextcind)}
 qb:saveqts; putdcc $idx "Done. Copied [llength $l] quotes from $fromc to $toc"
 if {$qb(logactions)} {qb:log "CPY DCC $h from $fromc to $toc"}
}

proc qb:delchan {h idx arg} {
 global qb qbl
 if {!$qb(chanspec)} {putdcc $idx "Command not available (script option \"channel specific quotes\" is disabled)"; return}
 set c [string tolower $arg]; set l ""
 if {[llength $arg] != 1} {putdcc $idx "Usage: delchanquotes <channel>"; return}
 foreach e [array names qbl] {if {[string match "#[lindex [split $e #] 2]" $c]} {lappend l $e}}
 if {[llength $l] == 0} {putdcc $idx "Can't find any quotes for $c."; return}
 foreach e $l {unset qbl($e)}; qb:saveqts; putdcc $idx "Done. Deleted [llength $l] quotes from $c."
 if {$qb(logactions)} {qb:log "DLC DCC $h $c"}
}

proc qb:delnew {what} {
 global qb qbl
 set pos [lsearch $qb(new) $what]; if {$pos > -1} {set qb(new) [lreplace $qb(new) $pos $pos]}
}

proc qb:random {c} {
 global qb qbl
 set l ""
 if {$qb(chanspec)} {
  foreach e [array names qbl] {if {[string match "#[lindex [split $e #] 2]" $c]} {lappend l $e}}; set i 1
  } else {
  foreach e [array names qbl] {lappend l $e}; set i 0
 }
 if {[llength $l] > 0} {set e [lindex $l [rand [llength $l]]]} else {return} 
 set e [lindex $l [rand [llength $l]]]; return "(#[lindex [split $e #] $i]) [qb:dr $qbl($e)]"
}

proc qb:findnn {c} {
 global qb qbl
 set alist ""; set clist ""; set a [array names qbl]
 foreach e $a {lappend alist [lindex [split $e #] 0]}
 set qb(nextind) [expr [lindex [lsort -decreasing -integer $alist] 0] + 1]
 foreach e $a {
  set el [split $e #]
  if {[string match "#[lindex $el 2]" $c]} {lappend clist [lindex $el 1]}
 }
 set qb(nextcind) [expr [lindex [lsort -decreasing -integer $clist] 0] + 1]
}

proc qb:rs {i} {
 global numversion
 regsub -all \\\\ $i !%01 i; regsub -all \\\[ $i !%02 i; regsub -all \\\] $i !%03 i
 regsub -all \\\} $i !%04 i; regsub -all \\\{ $i !%05 i; regsub -all \\\^ $i !%06 i
 regsub -all \\\" $i !%07 i; regsub -all \\\* $i !%08 i; regsub -all \\\? $i !%09 i
 if {$numversion < 1060400} {
  regsub -all Ä $i AE i; regsub -all ä $i ae i; regsub -all Ö $i OE i
  regsub -all ö $i oe i; regsub -all Ü $i UE i; regsub -all ü $i ue i
  regsub -all ß $i ss i; regsub -all Ý $i Y i; regsub -all ý $i y i
 }
 return $i
}

proc qb:dr {i} {
 regsub -all !%01 $i \\ i; regsub -all !%02 $i \[ i; regsub -all !%03 $i \] i
 regsub -all !%04 $i \} i; regsub -all !%05 $i \{ i; regsub -all !%06 $i \^ i
 regsub -all !%07 $i \" i; regsub -all !%08 $i \* i; regsub -all !%09 $i \? i
 return $i
}

if {[array exist qbt]} {unset qbt}
foreach t [timers] {if {[lsearch -regexp $t qb:scheduled] > -1} {killtimer [lindex $t 2]}}
set qb(new) ""; set qb(conversion) 0; qb:read
if {$qb(new) != ""} {set qbinsert ", [llength $qb(new)] new"} else {set qbinsert ""}
putlog "TCL LOADED: QuoteBot v2.0 by Baerchen. [llength [array names qbl]] Quotes in database${qbinsert}."
if {$qb(conversion)} {
 putlog "            Converted old database. Quotes assigned to channel #quotebot"
 putlog "            Use command .copyquotes to assign them to other channels"
 putlog "            This is _only_ needed if you chose to have channel specific quotes"
}
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Tue Oct 31, 2006 11:10 am    Post subject: Reply with quote

Try adding
Code:
set arg "($n) $arg"

after
Code:
if {$qb(chanspec)} {set index $qb(nextcind)} else {set index $qb(nextind)}

in the qb:addpub proc.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
fredvil
Voice


Joined: 01 Dec 2005
Posts: 21

PostPosted: Tue Oct 31, 2006 6:38 pm    Post subject: Reply with quote

hello Sir_Fz, this what ive got after adding set arg "($n) $arg". the nick is included on the quote when adding it but when i display the quote, the nick isn't there. pls check below, i added testing 123 and got a bot reply Added Quote #75: "(clarck) testing 123" but when i diplay the quote 75 my nick is not included on the quote.

Quote:
[06:12] <clarck> .addquote testing 123
[06:12] -botnick- Added Quote #75: "(clarck) testing 123"
[06:12] <clarck> .quote 75
[06:12] <botnick> (#75) testing 123


you help is very much appreciated
Back to top
View user's profile Send private message
fredvil
Voice


Joined: 01 Dec 2005
Posts: 21

PostPosted: Tue Oct 31, 2006 7:16 pm    Post subject: Reply with quote

Sir_Fz,

i got it... i put
Code:
set arg "$arg -$n"
after
Code:
set c [string tolower $c]
and it works... thanks a lot

Code:
proc qb:addpub {n uh h c arg} {
 global qb qbl
 set c [string tolower $c]
 set arg "$arg -$n"
 foreach b $qb(noaddchan) {if {[string match -nocase $c $b]} {return}}
 set arg [qb:rs $arg]
 if {[string length $arg] > $qb(max)} {puthelp "NOTICE $n :Quote exceeds $qb(max) characters. Yours has [string length $arg]."; return}
 if {[llength $arg] == 0} {puthelp "NOTICE $n :Usage: ${qb(trigger)}addquote <quote>"; return}
 if {$qb(chanspec)} {
  foreach e [array names qbl] {if {[string match "#[lindex [split $e #] 2]" $c] && [string match -nocase $qbl($e) $arg]} {set index [lindex [split $e #] 1]}}
  } else {
  foreach e [array names qbl] {if {[string match -nocase $qbl($e) $arg]} {set index [lindex [split $e #] 0]}}   
 }
 if {[info exists index]} {puthelp "NOTICE $n :The quote you tried to add already exists (index #$index)."; return}
 qb:findnn $c; set index $qb(nextind)#$qb(nextcind)$c; set qbl($index) $arg; lappend qb(new) $index; qb:saveqts
 if {$qb(chanspec)} {set index $qb(nextcind)} else {set index $qb(nextind)}
 puthelp "NOTICE $n :Added Quote #${index}: \"[qb:dr $arg]\""
 if {[llength $qb(new)] == 1} {
  if {$qb(sendnote) != ""} {
   if {[info commands sendnote] != ""} {
    if {[validuser $qb(sendnote)]} {sendnote QuoteBot $qb(sendnote) "New quotes available. Use .newquotes to list them."}
   }
  }
 }
 if {$qb(logactions)} {qb:log "ADD PUB $n $c (#$index) [qb:dr $arg]"}
}


Last edited by fredvil on Sat Jan 27, 2007 8:48 am; edited 1 time in total
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Tue Oct 31, 2006 7:21 pm    Post subject: Reply with quote

Contact the author then, I won't be reading through the code to figure this out.

Edit: Glad you found the solution Smile
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber