• Welcome to Valhalla Legends Archive.
 

Channel Type's?

Started by BaDDBLooD, March 07, 2004, 09:32 PM

Previous topic - Next topic

BaDDBLooD



Public Function GetChannelType(ByVal Flags As Long) As String

   Select Case Flags
       Case CHANNEL_PUBLIC&
           GetChannelType = "Public Channel"
       Case CHANNEL_MODERATED&
           GetChannelType = "Moderated channel"
       Case CHANNEL_RESTRICTED&
           GetChannelType = "Restricted Channel"
       Case CHANNEL_SILENT&
           GetChannelType = "Silent Channel"
       Case CHANNEL_SYSTEM&
           GetChannelType = "System CHannel"
       Case CHANNEL_PRODUCTSPECIFIC&
           GetChannelType = "Product Specific"
       Case CHANNEL_GLOBAL&
           GetChannelType = "Global Channel"
   End Select
   
End Function



Not sure if those are correct or not...
i tested a few of them out, it shows it shows clan, and op channels as public.  Although it showed channels like clan recruitment, kbk info etc.. as Nothing..

Little help? ;o
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

MyndFyre

#1
For future reference, when making words plural, you don't need to add an apostrophe.  "Types" is the correct transcription, not "type's."
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

o.OV

#2
I never thought anyone would care about channel flags.
Use zDS bot to compare..
I think zDS shows channel flag when you join a channel.

Add-On:
Where did you get that anyways.
I hate Constants.
You should comment the constants with actual value.
And have the channel flag display on screen
when you enter a channel.
If the facts don't fit the theory, change the facts. - Albert Einstein

BaDDBLooD

#3
i don't have a zds bot lol

i got them at bnetdoc's..

anyone else have Input?
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

Eric

#4
Quote from: BaDDBLooD on March 07, 2004, 09:54 PM
i don't have a zds bot lol
Quote from: BaDDBLooD on March 07, 2004, 09:55 PM
all i have to say is... bnet doc's
Learn how to use the edit button.

Fr0z3N


Public Function ChannelFlags(ByVal Flags As Long) As String
   Dim Result As String
   Dim StrFlags As String
   StrFlags = DecToBin(Flags)
   StrFlags = Right(StrFlags, Len(StrFlags) - 1)
   Do While Len(StrFlags) < 16
       StrFlags = "0" & StrFlags
   Loop
   
   If IsBit(StrFlags, 0) Then Result = "Public"
   If IsBit(StrFlags, 1) Then Result = Result & "Moderated"
   If IsBit(StrFlags, 2) Then Result = Result & "Restricted"
   If IsBit(StrFlags, 3) Then Result = Result & "Silent"
   If IsBit(StrFlags, 4) Then Result = Result & "System"
   If IsBit(StrFlags, 5) Then Result = Result & "Product-Specific"
   If IsBit(StrFlags, 11) Then Result = Result & "Globally-Accessible"
   If Flags = &H0 Then Result = "Private"
   
   ChannelFlags = Result
End Function


That works for me.

Grok

Quote from: o.OV on March 07, 2004, 09:45 PMAdd-On:
Where did you get that anyways.
I hate Constants.
You should comment the constants with actual value.

Ack.  CompSci 101.  Use Named Constants for repeated-use literal constants.  This significantly improves readability of code and maintainability.  If one of the constants changes values, you only have to change the definition.

Soul Taker

You both are missing the redirecting channel flag, 0x4000.

Fr0z3N

Quote from: Fr0z3N on March 07, 2004, 10:35 PM

   If IsBit(StrFlags, 4) Then Result = Result & "System"




I don't think I am.

Arta


iago

Quote from: Grok on March 07, 2004, 10:48 PM
Quote from: o.OV on March 07, 2004, 09:45 PMAdd-On:
Where did you get that anyways.
I hate Constants.
You should comment the constants with actual value.

Ack.  CompSci 101.  Use Named Constants for repeated-use literal constants.  This significantly improves readability of code and maintainability.  If one of the constants changes values, you only have to change the definition.

Agreed, I take off more and more marks on each assignment for using Literal constants.  But people still do it, so obviously they aren't reading my comments of WHY they lost marks.

Anyway, your problem is that you're using a case for flags.  I would recommend looking up the right way to do flags, and why it works, but, basically, use bitwise operations.

Instead of this:
select Flags
       Case CHANNEL_PUBLIC&
           GetChannelType = "Public Channel"

do this:

if((Flags AND CHANNEL_PUBLIC) <> 0)
   returnString = returnString + "public"

Or something like that.  Keep in mind it can be >1 type.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


tA-Kane

In case you find a channel that has flags that you aren't supporting, it would be a good idea to make a note of it. The codes I see here aren't making use of that, so I'll make an example:

Function ChannelFlagsToFlagString(Value As Integer, DoUnknown As Boolean, DoPrivate As Boolean) As String
 Dim FlagString As String
 Dim Flags As Integer
 
 CONST kChannelFlags_Public = 1//0x1
 CONST kChannelFlags_Moderated = 2//0x2
 CONST kChannelFlags_Restricted = 4//0x4
 CONST kChannelFlags_Silent = 8//0x8
 CONST kChannelFlags_System = 16//0x10
 CONST kChannelFlags_ProductSpecific = 32//0x20
 CONST kChannelFlags_Global = 4096//0x1000
 
 Flags = Value//set temporary usage to the channel's flags value
 
 //get all the flag strings
 //rules: check for a specific flag
 //if that flag doesn't exist (not 1), then move on
 //else, add ", " and the name of the flag to the flag string
 //then, remove the flag from the temporary buffer
 //why remove? allows to check for unknown flags at the end of the function
 If BitwiseAnd(Flags,kChannelFlags_Global) = kBnetGame_ChannelFlags_Global Then
   FlagString = FlagString + ", Global"
   Flags = BitwiseXOr(Flags,kChannelFlags_Global)
 End If
 If BitwiseAnd(Flags,kChannelFlags_ProductSpecific) = kBnetGame_ChannelFlags_ProductSpecific Then
   FlagString = FlagString + ", Product Specific"
   Flags = BitwiseXOr(Flags,kChannelFlags_ProductSpecific)
 End If
 If BitwiseAnd(Flags,kChannelFlags_System) = kBnetGame_ChannelFlags_System Then
   FlagString = FlagString + ", System"
   Flags = BitwiseXOr(Flags,kChannelFlags_System)
 End If
 If BitwiseAnd(Flags,kChannelFlags_Silent) = kBnetGame_ChannelFlags_Silent Then
   FlagString = FlagString + ", Silent"
   Flags = BitwiseXOr(Flags,kChannelFlags_Silent)
 End If
 If BitwiseAnd(Flags,kChannelFlags_Restricted) = kBnetGame_ChannelFlags_Restricted Then
   FlagString = FlagString + ", Restricted"
   Flags = BitwiseXOr(Flags,kChannelFlags_Restricted)
 End If
 If BitwiseAnd(Flags,kChannelFlags_Moderated) = kBnetGame_ChannelFlags_Moderated Then
   FlagString = FlagString + ", Moderated"
   Flags = BitwiseXOr(Flags,kChannelFlags_Moderated)
 End If
 If BitwiseAnd(Flags,kChannelFlags_Public) = kBnetGame_ChannelFlags_Public Then
   FlagString = FlagString + ", Public"
   Flags = BitwiseXOr(Flags,kChannelFlags_Public)
 End If
 
 //check for unknown flags
 If Flags <> 0 Then
   //check to make sure that the calling function wants to see the unknown flags
   If DoUnknown = True Then
     FlagString = ", Unknown ("+MyHex(Flags)+")"  
   End If
 End If
 
 //check for no flags at all (flags = 0 and flagstring is empty)
 If Flags = 0 And FlagString = "" Then
   //check to make sure calling function wants private channel string
   If DoPrivate = True Then
     FlagString = FlagString + ", Private"
   End If
 End If
 
 //return the string, without the first ", "
 Return Mid(FlagString,3)


Then, in the calling function, you would pass the channel's flags in the first parameter. If you want to display any unknown flags, pass true for the second parameter. And then if you want to display private channels (eg, no flags), pass true for the third.

Hopefully with this you'll be able to notice that BnetDocs is incomplete with regards to channel flags; there are 3 channel flags that BnetDocs does not document that are easily findable:

kChannelFlags_TechSupport
kChannelFlags_ChatAccessible
kChannelFlags_LoadBalanced (aka kChannelFlags_Redirected)

Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

Eli_1

#12
Quote from: tA-Kane on March 08, 2004, 01:54 PM
In case you find a channel that has flags that you aren't supporting, it would be a good idea to make a note of it. The codes I see here aren't making use of that, so I'll make an example:

Function ChannelFlagsToFlagString(Value As Integer, DoUnknown As Boolean, DoPrivate As Boolean) As String
 Dim FlagString As String
 Dim Flags As Integer
 
 CONST kChannelFlags_Public = 1//0x1
 CONST kChannelFlags_Moderated = 2//0x2
 CONST kChannelFlags_Restricted = 4//0x4
 CONST kChannelFlags_Silent = 8//0x8
 CONST kChannelFlags_System = 16//0x10
 CONST kChannelFlags_ProductSpecific = 32//0x20
 CONST kChannelFlags_Global = 4096//0x1000

 

btw, // won't work as comments with VB  :P

hismajesty

Seeing as how Kane doesn't use VB they may be the comment character used in his language (I forget the name, but it's said to be similar to VB). I guess, the Mac version of VB. :P

BaDDBLooD

#14
Quote from: Fr0z3N on March 07, 2004, 10:35 PM

Public Function ChannelFlags(ByVal Flags As Long) As String
   Dim Result As String
   Dim StrFlags As String
   StrFlags = DecToBin(Flags)
   StrFlags = Right(StrFlags, Len(StrFlags) - 1)
   Do While Len(StrFlags) < 16
       StrFlags = "0" & StrFlags
   Loop
   
   If IsBit(StrFlags, 0) Then Result = "Public"
   If IsBit(StrFlags, 1) Then Result = Result & "Moderated"
   If IsBit(StrFlags, 2) Then Result = Result & "Restricted"
   If IsBit(StrFlags, 3) Then Result = Result & "Silent"
   If IsBit(StrFlags, 4) Then Result = Result & "System"
   If IsBit(StrFlags, 5) Then Result = Result & "Product-Specific"
   If IsBit(StrFlags, 11) Then Result = Result & "Globally-Accessible"
   If Flags = &H0 Then Result = "Private"
   
   ChannelFlags = Result
End Function


That works for me.


Now i just need the IsBit, and DecToBin functions :P
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.