Valhalla Legends Forums Archive | Visual Basic Programming | [VB? - extracting text fields] Commands ("kick" , "ban exe)

AuthorMessageTime
titan0060
Ok, im trying to program commands into my bot, but i've only been able to get !ver because it doesn't run a second word.

when i say... !Kick JohnDoe
is there a way i can have my bot pick up the !Kick without the JohnDoe.

Help me out plz

[Kp edit: gave him a new title, then kicked him out of botdev. His question is about basic text parsing, which belongs in the forum of his language of choice.]
August 30, 2004, 3:28 PM
St0rm.iD
You need to ***LEARN VB!***

And don't say you do, this is a trivial task.

Hint: use Split()
August 30, 2004, 3:34 PM
Quarantine
I might be able to put together ban.exe :P
August 30, 2004, 5:11 PM
Grok
[quote author=$t0rm link=board=31;threadid=8465;start=0#msg78159 date=1093880087]
You need to ***LEARN VB!***

And don't say you do, this is a trivial task.

Hint: use Split()
[/quote]

Yes, Split, Join, Choose, and Switch are all excellent useful VB functions for text processing. Learn them all!
August 30, 2004, 7:16 PM
Stealth
Mid$() and InStr() are also essential.
August 31, 2004, 5:08 AM
Eli_1
I use Right() and Left() a lot.
August 31, 2004, 10:30 AM
The-Rabid-Lord
Lcase = and Rcase =
August 31, 2004, 3:18 PM
St0rm.iD
Ever since discovering regex, I can't go back.
August 31, 2004, 3:19 PM
KkBlazekK
Don't forget UCase!
September 2, 2004, 2:11 AM
dRAgoN
Might want to look up the 'if' statment aswell, since you will probably use that quite often.
September 2, 2004, 4:44 PM
R.a.B.B.i.T
And Split() can be helpful sometimes.
September 4, 2004, 3:08 AM
Forged
if lcase(message)="!kick" & name then
csb.send = "/kick" &name

Assuming you are using csb and have name defined as a string

(I have no idea what you are asking but this seemed like it)
September 4, 2004, 4:38 AM
St0rm.iD
This regex should do it for you:

%c(\w+?)\s*?(.*?)

And sub in your trigger for %c. Command name will be group 1, args will be group 2.
September 4, 2004, 1:42 PM
LivedKrad
[Let us assume that the thread starter was referring to Visual Basic!]


[quote author=Forged link=board=31;threadid=8465;start=0#msg78994 date=1094272724]
if lcase(message)="!kick" & name then
csb.send = "/kick" &name

Assuming you are using csb and have name defined as a string

(I have no idea what you are asking but this seemed like it)
[/quote]

So, we would have to look at this assuming the variable "name" is declared as a sectioned part of the message? For instance, if I wanted to extract "Forged" from ".kick Forged", and I set up a control flow statement to extract "name", it's going to give some goofy error. You'll need to have something to the effect of...
[code]
Public name as String


If LCase(message) = someTrigVar & "kick " Then
name = mid$(message, 6) 'Extract all text from the 'message' variable starting from position 6; can be reused so long as the variable receives a new value per action
WhateverObject.Send "/kick " & name
End If
[/code]
September 12, 2004, 5:49 AM

Search