Valhalla Legends Forums Archive | Battle.net Bot Development | Another moderation bot...

AuthorMessageTime
GSX
I am currently a mediocore (at best) Visual Basic 6 programmer, and I have coded a bot for Bnet before, and I dislike most all moderation bots out there. So yes, I'm off to code yet ANOTHER one! I have a pretty general idea of how to do this, but I'm not 100% sure about all things, and I've researched all I could.

So here's my layout; moderation bot, no channel list, basic text viewing window (Showing Bnet info, issued commands, bot info), multiple profile loading (no tabbing, just simply loading them out of 1 exe), being able to have profiles respond both individually, and have some grouped bot commands (like NF has for loadbanning), and some other various things that are minor details to others, but are large reasons why I am coding this.

My issues arise at the connections/profile loading.

I currently use BNCSUtil to connect to Battle.net, and I am not sure how well this will work for multiple profile loading (I believe I read somewhere that it is not good at all for this purpose?). Another thing is how I will be loading the profiles. I am wondering if it would be best for me to do it all in one Config.ini, or maybe the way TriCk did it in Mirage with the Profiles folder, using an individual .ini for each one.

Well, this is just a basic overview, with my ideas and possible issues. What do you think of it, and any ideas about my issues are also appreciated. Oh, and I'm not looking for source code handouts, don't want 'em. I want to do this to actually EXCERCISE my Visual Basic skills.

Thanks!
May 16, 2006, 12:12 AM
warz
Just make all the bots respond to every command, and for an individual bot to respond to a command put it's name after the trigger..

ie: .ban anonymous - would make every bot try to ban anonymous
    .bot3 ban anonymous - would make only bot 3 try to ban.
May 16, 2006, 12:42 AM
Topaz
[quote author=warz link=topic=14989.msg152532#msg152532 date=1147740142]
Just make all the bots respond to every command, and for an individual bot to respond to a command put it's name after the trigger..

ie: .ban anonymous - would make every bot try to ban anonymous
    .bot3 ban anonymous - would make only bot 3 try to ban.
[/quote]

Difficult in action, since operator names can get rather long, as well as other users not knowing the indices of the various bots.
May 16, 2006, 1:10 AM
GSX
Yeah, right now I'm leaning towards a method of having all bots somehow set in an array I think it is? (Unsure, but here's how I'm sort of thinking)

[code]
'This would be like in a CheckCommand sub or something...

Select Case Mid(Message, 1, 1)

    Case Bot(1).Trigger
          'Have the bot check for commands and send it via Bot(1)'s command queue

    Case Bot(2).Trigger
          'Have the bot check for commands and send it via Bot(2)'s command queue

      Case Etc, etc.

End Select
[/code]

Yeah, I couldn't describe it... But I don't know if this is even possible, so yeah... Thoughts? =/
May 16, 2006, 1:50 AM
l2k-Shadow
[quote author=GSX link=topic=14989.msg152536#msg152536 date=1147744204]
Yeah, right now I'm leaning towards a method of having all bots somehow set in an array I think it is? (Unsure, but here's how I'm sort of thinking)

[code]
'This would be like in a CheckCommand sub or something...

Select Case Mid(Message, 1, 1)

    Case Bot(1).Trigger
          'Have the bot check for commands and send it via Bot(1)'s command queue

    Case Bot(2).Trigger
          'Have the bot check for commands and send it via Bot(2)'s command queue

      Case Etc, etc.

End Select
[/code]

Yeah, I couldn't describe it... But I don't know if this is even possible, so yeah... Thoughts? =/

[/quote]

Easiest way (not best) is to have all your crap in a class module and have like a seperate class module for each bot and indexed objects that you need.

You could also just do a user control, but that's worse than a class.
Declares:
[code]Public BOT() as clsBOT[/code]
Main Form:
[code]Private Sub Form_Load()
    Set BOT(0) = New clsBOT
End Sub[/code]
Unloading Profile:
[code]Set BOT(i) = Nothing[/code]
Loading Profile:
[code]ReDim Preserve BOT(i)
Set BOT(i) = New clsBOT[/code]

is kind of the thing you need for it... should be understandable enough. note it's not the best way to multi-profile but it's easy and efficient enough.
May 16, 2006, 3:48 AM
LoRd
It would be cleaner to use a collection.
May 16, 2006, 4:52 AM
HeRo
Doesn't a collection take up more memory?
May 16, 2006, 6:13 AM
rabbit
Yes, but it's also less hassle.
May 16, 2006, 11:44 AM
shout
You could have a 'master bot' recieve all the commands, then have one of the other bots process and send it out.

Psuedocode:
[code]
function blahblahblah msg as whatever
If validmsg Then
AddToQueue msg

function otherblah
msg = GetMessageFromQueue
Bot = GetBestBotInstanceForTheJob
ProcessMsg Bot, msg
[/code]

I don't really know if this is what you are inquirng about though...
May 16, 2006, 2:02 PM
GSX
All right, I think I am going to take the .cls method, as that sounds like something I could do...

Now about the multiple connections...

I am not sure as to how to have multiple connections run via 1 winsock. I was thinking of creating an array, but that's not possible (I don't think..., and I don't think that's even the right way to go about it). I have put some serious thought into it, and can't seem to figure it out, which sort of pisses me off.

Any suggestions/thoughts to kick me to the right path?
May 17, 2006, 12:12 AM
Networks
[quote author=HeRo link=topic=14989.msg152545#msg152545 date=1147759987]
Doesn't a collection take up more memory?
[/quote]

If your computer can't handle a couple mb's of memory, sell it.
May 17, 2006, 12:28 AM
rabbit
[quote author=GSX link=topic=14989.msg152592#msg152592 date=1147824768]
I am not sure as to how to have multiple connections run via 1 winsock.[/quote]It's not possible.

[quote]I was thinking of creating an array, but that's not possible[/quote]It is.  Control arrays behave differently than variable arrays.  You can't just instantiate a new index and have it poof into existance like you can in variable arrays, you must first create the new index and then Load it.
May 17, 2006, 12:45 AM
warz
GSX, i think what rabbit is telling you is that you cannot use one socket to handle connections for multiple online bots. What you need to do is have multiple sockets. Now, in visual basic the winsock control is a wrapper around functions that handle winsock related tasks. You can create an array of winsock classes, which results in multiple sockets which can allow you to connection multiple clients to bnet at once. I'm sure there's enough code floating around these forums, and other sites, with examples of how to create an array of winsock controls.

You'll need some global identifier that lets you know how many sockets you currently have running, etc, in order to properly handle your array of winsock controls.
May 17, 2006, 1:01 AM
GSX
Yeah, I got what he was saying. Thanks much for all the help fellows, I'm now off to research how to create an array of winsock controls (creating/loading them, etc).

I'll post back whenever another issue arises.
May 17, 2006, 1:18 AM
HeRo
[quote author=Networks link=topic=14989.msg152593#msg152593 date=1147825695]
[quote author=HeRo link=topic=14989.msg152545#msg152545 date=1147759987]
Doesn't a collection take up more memory?
[/quote]

If your computer can't handle a couple mb's of memory, sell it.
[/quote]
I never said it couldn't, I was just wondering if it did, and as rabbit confirmed, it does, good day sir :).
May 17, 2006, 1:41 AM
LoRd
[quote author=HeRo link=topic=14989.msg152601#msg152601 date=1147830065]
[quote author=Networks link=topic=14989.msg152593#msg152593 date=1147825695]
[quote author=HeRo link=topic=14989.msg152545#msg152545 date=1147759987]
Doesn't a collection take up more memory?
[/quote]

If your computer can't handle a couple mb's of memory, sell it.
[/quote]
I never said it couldn't, I was just wondering if it did, and as rabbit confirmed, it does, good day sir :).
[/quote]

The difference would be nominal and even moreso if you were to factor in the ease of management that a collection would provide.
May 17, 2006, 2:00 AM
GSX
Woooo I'm back already...

This question is about loading profiles, I got them going ok...

But here's the issue I'm faced with, currently I'm loading all of them from 1 Configuration.ini.

The code looks like this:

[code]
Public Function GetProfileCount()
Dim x As Integer, xString As String, CheckFor As String

x = 1

Check:
xString = x

CheckFor = GetStuff(xString, "Username")

    If CheckFor = "#FINAL" Then
        ProfileCount = x
        Exit Function
    Else
        x = x + 1
        GoTo Check
    End If


End Function
[/code]

So basically, I'm not sure how to have the program know how many profiles there are. This current method works all right, assuming the user is smart enough to know that when they alter Configuration.ini, they must change the last profile's number... And keep them in the correct order, as currently it would read them like this:

[code]
'Example of Configuration.ini
[0] 'Known as Bot(0), or master, not counted by this...
Username=UserA
Password=PassA
Server=ServerA
'Etc

[1] 'Bot(1)
Username=UserB
Password=PassB
Server=ServerB
'Etc

[2]
Username=UserC
Password=PassC
Server=ServerC
'Etc

[3]
Username=#FINAL 'Tells _ProfileCount_ function that there are 2 WORKING profiles...
[/code]

Any suggestions on how to fix this/other methods of loading profile data from the .ini?
May 17, 2006, 2:14 AM
LoRd
You can either:

1.) Include a section in your configuration file that would allow users to select which profiles (or how many profiles) they would like the bot to load.
2.) Scan for or attempt to load each profile.
May 17, 2006, 3:15 AM
rabbit
A beauty of ini files: order doesn't matter.  As long as all the fields are in the right section, everything should be just fine.
May 17, 2006, 3:19 AM
GSX
Agh, I'm an idiot and I want to sleep, but I want to finish this one last thing before I drop dead...

I am used to using _Private Sub Socket_Connect()_ for my bot's outgoing connection, how do I do this with a winsock control array? Lol, I've even tried Socket(i)_Connect()... Like a complete idiot, that's how tired I am.
May 17, 2006, 3:29 AM
warz
[quote author=rabbit link=topic=14989.msg152612#msg152612 date=1147835951]
A beauty of ini files: order doesn't matter.  As long as all the fields are in the right section, everything should be just fine.
[/quote]

Note that "order not mattering" is not a property of "ini" files. This all depends on how your file reading function handles the file data.
May 17, 2006, 4:57 AM
raylu
OK, to split hairs, "order not mattering" is a great feature of the API that most people use to read INI files...

[quote author=GSX]I am used to using _Private Sub Socket_Connect()_ for my bot's outgoing connection, how do I do this with a winsock control array? Lol, I've even tried Socket(i)_Connect()... Like a complete idiot, that's how tired I am.[/quote]
Cut your code in the Socket_Connect() sub. Delete the sub. Double click on the socket object and choose Connect. Poof, Index as Integer!
May 17, 2006, 5:01 AM
Topaz
Socket(Index as Integer) is what you should have
May 17, 2006, 5:14 AM
FrOzeN
[quote author=GSX link=topic=14989.msg152613#msg152613 date=1147836585]
Agh, I'm an idiot and I want to sleep, but I want to finish this one last thing before I drop dead...

I am used to using _Private Sub Socket_Connect()_ for my bot's outgoing connection, how do I do this with a winsock control array? Lol, I've even tried Socket(i)_Connect()... Like a complete idiot, that's how tired I am.
[/quote]
[code]Private Sub Socket_Connect(Index As Integer)[/code]
Also, to get all the sections of a .ini file. You'll need to go through open the file and process it to find them all.

This is how I did it just recently with a bot I'm working on:
[code]Dim strLine As String, intConfig As Integer, strPath As String
If Right$(App.Path, 1) = Chr$(47) Then strPath = App.Path Else strPath = App.Path & Chr$(47)
intConfig = FreeFile
Open strPath & "Config.ini" For Input As intConfig
    While Not EOF(intConfig)
        Line Input #intConfig, strLine
        If Left$(strLine, 1) = Chr$(91) Then
            lstProfiles.AddItem Left$(Mid$(strLine, 2), Len(strLine) - 2)
        End If
    Wend
Close intConfig[/code]
That would add them all to a ListBox named "lstProfiles". :)
May 17, 2006, 8:34 AM
rabbit
That's horrid.  Have a section for profile names.
May 17, 2006, 2:20 PM
Quarantine
Oh my god.
And like I've said on other forums many times, the amount of memory it takes to use a collection is slightly bigger but it's outweighed by the functionality and organization you get.
May 17, 2006, 2:27 PM
warz
configuration file handling is one of the more trivial aspects of a bot, in my opinion. grab the data bu whatever means, and store it. just avoid reading the config file more than needed.
May 17, 2006, 4:00 PM

Search