Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bind pub - "!smart" quotes:smart
- bind pub - "!gossip" quotes:gossip
- set g_lastsearcher ""
- set g_lastquoteno 0
- set g_lastsearch ""
- proc quotes:getquote { nick type arg } {
- global vote_config botnick g_lastsearcher g_lastsearch g_lastquoteno
- switch $type {
- "smart" {
- set fp [open "text/smart.txt" "r"]
- }
- "gossip" {
- set fp [open "text/gossip.txt" "r"]
- }
- }
- set quotes [split [read $fp] "\n"]
- if {[string length $arg] > 0} {
- if {[isnumber $arg]} {
- set quoteno [lindex $arg 0]
- if {$quoteno > [llength $quotes]} {
- return -1
- }
- } else {
- if {$g_lastsearcher == $nick && $g_lastsearch == $arg} {
- set quoteno [lsearch -start [expr $g_lastquoteno + 1] -glob $quotes "*$arg*"]
- } else {
- # Try to find it
- # If quoteno is the last, try one more time
- set quoteno [lsearch -glob $quotes "*$arg*"]
- }
- if {$quoteno == -1} {
- return -1
- }
- }
- } else {
- set quoteno [rand [llength $quotes]]
- }
- close $fp
- set g_lastsearcher $nick
- set g_lastsearch $arg
- set g_lastquoteno $quoteno
- return "$quoteno [lindex $quotes $quoteno]"
- }
- proc quotes:smart { nick uhost hand channel arg } {
- global vote_config
- set ret [quotes:getquote $nick "smart" $arg]
- if {$ret == -1} {
- puthelp "PRIVMSG $channel :$vote_config(code1)Quote containing $vote_config(code2)${arg}$vote_config(code1) not found"
- } else {
- puthelp "PRIVMSG $channel :$vote_config(code1)SMART [lindex $ret 0]:$vote_config(code2) [lrange $ret 1 end]"
- }
- }
- proc quotes:gossip { nick uhost hand channel arg } {
- global vote_config
- set ret [quotes:getquote $nick "gossip" $arg]
- if {$ret == -1} {
- puthelp "PRIVMSG $channel :$vote_config(code1)Quote containing $vote_config(code2)${arg}$vote_config(code1) not found"
- } else {
- puthelp "PRIVMSG $channel :$vote_config(code1)GOSSIP [lindex $ret 0]:$vote_config(code2) [lrange $ret 1 end]"
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement