Dynamic Topics - OverKill Script

By TMFKSOFT on May 02, 2013

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:

topic set/reset/update/append [value]

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.

  • The #topic append
    This will append data onto the issued var.
    Syntax: #topic append item value

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:

topic set pattern @topic

topic set topic Some Topic here

now you can just use:

topic set topic Some topic here.

For an Advanced topic use the following:

topic set pattern @topic @divider @owner @verb @status @divider @static

topic set topic Welcome to my channel!

topic set divider -!-

topic set owner MyNick

topic set verb is

topic set status Online!

topic set static Visit Hawkee! http://hawkee.com/

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 set status $iif(YourNick ison $chan,Online,Offline)

; 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
  }
}

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.