Skip to content
Permalink
Browse files

Add FullName property to user object

Returns the name of the user and their gateway. Follows the same
conversion rules as using the "Show All" namespace convention.

Also added optional arguments to modCommands.ConvertUsername and
modCommands.ConvertUsernameGateway to allow a convention to be specified
other than the bot's current one. This number is the same as the
conversion type used in these functions.
0 = none, 1 = legacy, 2 = wc3, 3 = all
  • Loading branch information...
Davnit committed Apr 19, 2016
1 parent e57de70 commit 37839f1673bbdd10468a3bd456cb16e6196ee932
Showing with 14 additions and 4 deletions.
  1. +6 −0 trunk/clsUserObj.cls
  2. +8 −4 trunk/modCommands.bas
@@ -127,6 +127,12 @@ Public Property Get DisplayName() As String
DisplayName = ConvertUsername(m_actual_name)
End Property

' Converts the username to always contain the gateway
' 3 = gateway convention: show all
Public Property Get FullName() As String
FullName = ConvertUsername(m_actual_name, 3)
End Property

Public Property Get Flags() As Long
Flags = m_flags
End Property
@@ -1476,20 +1476,20 @@ Private Function CheckUser(ByVal User As String, Optional ByVal allow_illegal As
End Function

' this fully converts a username based on naming conventions
Public Function ConvertUsername(ByVal Username As String) As String
Public Function ConvertUsername(ByVal Username As String, Optional ByVal iConvention As Integer = -1) As String
If (LenB(Username) = 0) Then
ConvertUsername = Username
Else
' handle namespace conversions (@gateways)
ConvertUsername = ConvertUsernameGateway(Username)
ConvertUsername = ConvertUsernameGateway(Username, iConvention)

' handle D2 naming conventions
ConvertUsername = ConvertUsernameD2(ConvertUsername, Username)
End If
End Function

' this converts a username only on gateway conventions
Public Function ConvertUsernameGateway(ByVal Username As String) As String
Public Function ConvertUsernameGateway(ByVal Username As String, Optional ByVal iConvertType As Integer = -1) As String
Dim Index As Long ' index of substring in string
Dim Gateways(5, 2) As String ' list of known namespaces
Dim blnIsW3 As Boolean ' whether this bot is on WC3
@@ -1518,7 +1518,11 @@ Public Function ConvertUsernameGateway(ByVal Username As String) As String
(StrReverse$(BotVars.Product) = PRODUCT_W3XP))

' store how we will be converting namespaces
intConvert = BotVars.GatewayConventions
If (iConvertType = -1) Then
intConvert = BotVars.GatewayConventions
Else
intConvert = iConvertType
End If

' get my gateway
MyGateway = BotVars.Gateway

0 comments on commit 37839f1

Please sign in to comment.
You can’t perform that action at this time.