• Welcome to Valhalla Legends Archive.
 

Message Variables

Started by Blade_360, March 14, 2003, 12:48 PM

Previous topic - Next topic

CupHead

Anyway...  Getting back to the subject at hand.  What Warblade wants is to create a set of multi-purpose aliases, much like the aliases/variables supported in ? Bot.  From the documentation:

Quote
   Aliases and variables are fun things, sometimes helpful.  Anyway, a brief explanation.  When you open the Variables tab on the Options dialog, you might not see anything.  That's normal.  To use them, add the alias or variable and then a space and then what you want it to represent.  For example:

/vL /join Clan [vL]

Then click Save.  Now when you type /vL in the send textbox, it will be replaced with /join Clan [vL].  For variables:

%blah% I'm so freaking bored!

Similarly, when you type %blah% in the send textbox, it is replaced with I'm so freaking bored!.  They're useful for shortening things.  Note the %s around the variable name.  These are not necessary, but they help identify variables and you're unlikely to ever type %blah% without wanting it to be replaced.  Hell, if you're like me and want to "lol" but don't want to ruin the appearance of perfect typing, add this:

lol
* CupHead laughs out loud.

Hope you get the idea.

Also, ? Bot supports a few internal variables.

%mp3% - The MP3 currently playing, including it's position on your playlist and the position in the song.
%channel% - The channel the bot is currently in.
%server% - The server the bot is currently connected to.
%ver% - The version of the bot.

Yeah, so back to how that's implemented.  My bot has a queue and as it sends, variables are replaced with actual values.  For example:


Private Function ReadFromQueue() As String
 ReadFromQueue = ReplaceStuff(Queue.Read)
 Send ReadFromQueue
End Function

Private Function ReplaceStuff(ByVal TheString as String) as String
 TheString = Replace(TheString, "%mp3%", WinAmp.GetSongTitle)
 TheString = Replace(TheString, "%channel%", CurrentChannel)
 TheString = Replace(TheString, "%server%", CleanSlateBot1.Server)
 ReplaceStuff = TheString
End Function


Anyway, that should about cover how it's done.  Note that this is very similar to what warz posted as well.

|