• Welcome to Valhalla Legends Archive.
 

Message Variables

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

Previous topic - Next topic

Blade_360

How do I set variables for stuff like Greeting Messages and Idles?
I've tried doing just
Dim channel As String
or
Dim %channel As String
but then it says invaild character

iago

#1
dim channel as String

channel = "Hi, this bot sucks!"
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


PaiD

#2
I think it would be like this

Dim %Chan as string

%Chan = frmmain.txtchannel.text

Banana fanna fo fanna

#3
I don't.

Blade_360

maybe I should rephase this
it won't let me do stuff like
Dim !example As String
Dim @example As String
Dim #example As String
I want to know how you do it. I know it can be done because I've seen VB bots that can do it

Noodlez

#5
you cant. what you probably saw was dim bleh$  that's just declaring it as a string $ = string % = integer & = long

iago

#6
If he seen bots do it, he might be talking about commands, like:
"!ban iago[vL] You're too awesome for us"

Maybe he doesn't realize the distinction between the variable name and the contents or something.  
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Blade_360

no I don't mean stuff like triggers I mean as in Idles
like

/w %username Welcome to %channel
[EDIT:]I figured it out

ILurker

lol
at the top of your source put
Dim CurrentChan as stringfor the onchannel event make it set that variable as the channelname
CurrentChan = channelnamethen for the onuser event do something like this
Send "/w " & username & " " & message

warz

This might work.

'Possible usage
Private Sub Form_Load()
    Text1.Text = format_message("%greet The current time is %time, and %variable_message")
End Sub

'Replace function
Private Sub replace_variable(ByVal full_message As String, ByVal custom_variable As String, _
                             ByVal custom_alternative As String, ByRef final_message)
    final_message = Replace(full_message, custom_variable, custom_alternative)
End Sub

'Format message function
Private Function format_message(ByVal full_message As String) As String
Const variable_message = "This is the variable message that states that warz owns me!"
    Call replace_variable(full_message, "%time", Time, full_message)
    Call replace_variable(full_message, "%greet", "Greetings!", full_message)
    Call replace_variable(full_message, "%variable_message", variable_message, full_message)
    format_message = full_message
End Function

Spht

#10
QuoteOr, you could just use instr() and replace().
I haven't done this in awhile, but it might look something like:

if instr(1, idlemessage, variable_chan) <> 0 then
   replace(idlemessage, variable_chan, current_chan)
end if

I will download visual basic 6 again, and produce some simple examples, with decent commentary.

It is not necessary to use InStr() before using Replace(). If Replace() can not find the string it searched for, it will return the unchanged original string.

Atom

#11
Dim declares your variable and sets its type.

Dim blah as string
blah = "hi"

That creates the variable named blah and puts "hi" into it.

now if you didnt dim your variable
blah = "hi"

that makes blah a variant... which takes a lot of memory.

but if you do:

blah$ = "hi"

that makes blah a string without using the dim statement.
I am back! aINC is dead, ThinkTank PRO is alive.
VB, JAVA, ASM, C, its all yummy to me.

warz

Quoteno I don't mean stuff like triggers I mean as in Idles
like

/w %username Welcome to %channel
[EDIT:]I figured it out
he dint knowhow to explain how he wass aksing i dont think. loojks like he confused %variables n the bots like raibnot where u cant put them in the idle mesgaes and greetgs and stuff and it rpelaces them, with vaibrles in visula basic compiler,

soryr ill fix thix tomrrow   :- :-/

Camel

#13
QuoteDim declares your variable and sets its type.

Dim blah as string
blah = "hi"

That creates the variable named blah and puts "hi" into it.

now if you didnt dim your variable
blah = "hi"

that makes blah a variant... which takes a lot of memory.

but if you do:

blah$ = "hi"

that makes blah a string without using the dim statement.
put "option explicit" on the first line of all your modules/forms/whatever
also go to options->tools and check require variable declaration, so that it will automaticly put option explicit at the top for you

Grok

#14
Everyone has enough experience with bots to evolve them to a higher level of abstraction, so I submit the following.

As programmers we look for ways to write code that reduces our dependency on implementation rules.  In other words, we want to write as much abstract code as we can.  The more functions we write that do good work, yet know nothing about why they're doing it, the smaller our programs can become, and the easier it is to write the rules-specific implementation.

For example, I can write code to cook an egg (i'll get back to bots in a minute):

Dim MyEgg as New PoultryLib.Egg
Dim MyPan As New KitchenwareLib.Skillet
MyEgg.Color = Brown
MyEgg.Size = Large
MyEgg.Grade = A
MyEgg.CrackOpen MyPan.CookingSurface

That uses a pretty decent level of abstraction, because the code in the Egg class doesn't know what we're going to do with the egg.  It merely provides properties and methods for us to do egg-like things.

Bots
Bots are a mature entity in the programming world, and we should have highly abstracted their programming some time ago.  In fact, it has been done to some degree as far back on battle.net as nbbot.  Remember nbbot.cfg?  I wrote a tutorial that described how to use nbbot and categorized the abstracted segments of a line as event triggers, conditions, actions, and I forgot what I named the final part or event what it did.

&trigger&condition&action&....?

Now here we are, years later, and nearly everyone is writing tightly coupled commands for your bots.

Users of your bots should be able to name commands whatever they want, should be able to put whatever conditions they want, and define one or multiple actions that result from the conditions being met.

Why is that possible?  Because there is a finite set of events and objects exposed on battle.net  Your job as the bot programmer is to expose interfaces to things like:

channels
users
emotes
talks
whispers
infos

There are more but the list is small.  You should be programming in a generic way around those objects.  Let your users decide precisely how they will happen.  Write most of the standard usages yourself and distribute those with your bot.  Then give them an understanding of how to add rules themselves and customize as they see fit.

I'd like to see what you guys come up with.