I've been writing a new bot lately and decided I wanted to add a topic function, so I wrote a full dynamic topic system.
I know theres already scripts out there. but I dont care..
Usage:
This topic script is going to be very fun to explain. Trust me.
The #topic set
This command will allow you to set your custom variables. The topic is read from the custom variable 'pattern'
Variables start with @ and can be any value you wish.
Syntax: #topic set blah value
When you set a var the topic is updated automatically.
You can remove a var via #topic del var
The #topic reset
This will clear ALL variables set for the topic. Pattern included.
The #topic update
This will update the topic in the channel incase its been manually set.
Already I know there will be newbies reading the script. So heres some examples.
For a simple simple topic. I mean. SIMPLE.
Paste the following in the channel when the script is loaded:
now you can just use:
For an Advanced topic use the following:
Bear in mind, Variables can be anything. You're not restricted to the ones above. Patterns can be any length and more.
Experiment and have fun!
P.s.
; Topic Script
on 1:TEXT:#topic*:#:{
if ($nick isop $chan) {
if ($2 == set) {
writeini topics.ini $+($network,.,$chan) $3 $4-
msg # Set $+(',$3,') to $(',$4-,')
topic $chan $topicparse($readini(topics.ini,$+($network,.,$chan),pattern))
}
else if ($2 == get) {
msg # $3 = $topicget($3)
}
else if ($2 == append) {
writeini topics.ini $+($network,.,$chan) $3 $topicget($3) $4-
msg # Appended $(',$4-,') to $+(',$3,')
}
else if ($2 == reset) {
remini(topics.ini,$+($network,.,$chan))
msg # Cleared Topic Data for $chan
}
else if ($2 == update) {
topic $chan $topicparse($readini(topics.ini,$+($network,.,$chan),pattern))
}
}
}
alias topicparse {
; Now to parse this shizzle.
var %ret
var %pattern $1-
var %i 1
log 4 Parsing %pattern
while (%i <= $calc($count(%pattern,$chr(32)) +1)) {
echo Number %i / $count(%pattern,$chr(32)) - $gettok(%pattern,%i,32)
if ($left($gettok(%pattern,%i,32),1) == @) {
; It's a var people.
var %item $right($gettok(%pattern,%i,32),-1)
var %value $topicget(%item)
echo $gettok(%pattern,%i,32) IS a VAR and its ITEM is %item adding value of %value to $+(',%ret,')
var %ret %ret %value
}
else {
echo $gettok(%pattern,%i,32) is NOT a VAR
var %ret %ret $gettok(%pattern,%i,32)
}
inc %i
}
return %ret
}
alias topicget {
; For the sake of Topic Parse
echo Checking for $1 in ini for $+($network,.,$chan)
var %ret $readini(topics.ini,$+($network,.,$chan),$1)
if (%ret != $null) {
return %ret
}
else {
return $1
}
}