diff --git a/trunk/frmChat.frm b/trunk/frmChat.frm index f94aacbd..583117ef 100644 --- a/trunk/frmChat.frm +++ b/trunk/frmChat.frm @@ -6174,18 +6174,7 @@ Private Sub tmrIdleTimer_Timer_IdleMsg() Exit Sub End If - IdleMsg = Replace(IdleMsg, "%cpuup", ConvertTimeInterval(GetTickCountMS())) - IdleMsg = Replace(IdleMsg, "%chan", g_Channel.Name) - IdleMsg = Replace(IdleMsg, "%c", g_Channel.Name) - IdleMsg = Replace(IdleMsg, "%me", GetCurrentUsername) - IdleMsg = Replace(IdleMsg, "%v", CVERSION) - IdleMsg = Replace(IdleMsg, "%ver", CVERSION) - IdleMsg = Replace(IdleMsg, "%bc", BanCount) - IdleMsg = Replace(IdleMsg, "%botup", ConvertTimeInterval(GetConnectionUptime())) - IdleMsg = Replace(IdleMsg, "%mp3", Replace(MediaPlayer.TrackName, "&", "+")) - IdleMsg = Replace(IdleMsg, "%quote", g_Quotes.GetRandomQuote) - IdleMsg = Replace(IdleMsg, "%rnd", GetRandomPerson) - IdleMsg = Replace(IdleMsg, "%t", Time$) + IdleMsg = DoReplacements(IdleMsg) If (IdleMsg = vbNullString) Then IsError = True @@ -7683,18 +7672,6 @@ Function GetFriendsSelectedUser() As String GetFriendsSelectedUser = CleanUsername(ReverseConvertUsernameGateway(lvFriendList.SelectedItem.Text)) End Function -Function GetRandomPerson() As String - Dim i As Integer - - If (g_Channel.Users.Count > 0) Then - Randomize - - i = Int(g_Channel.Users.Count * Rnd + 1) - - GetRandomPerson = g_Channel.Users(i).DisplayName - End If -End Function - Function MatchClosest(ByVal toMatch As String, Optional startIndex As Long = 1) As String Dim lstView As ListView diff --git a/trunk/frmSettings.frm b/trunk/frmSettings.frm index 95f7df02..1e94a8fc 100644 --- a/trunk/frmSettings.frm +++ b/trunk/frmSettings.frm @@ -4637,26 +4637,27 @@ Private Sub Form_Load() .ListIndex = 0 End With - lblGreetVars.Caption = "Greet Message Variables: (Suggest more! email stealth@stealthbot.net) " & vbNewLine & _ - "%c = Current channel" & vbNewLine & _ - "%0 = Username of the person who joins" & vbNewLine & _ - "%1 = Bot's current username" & vbNewLine & _ - "%p = Ping of user who joins" & vbNewLine & _ - "%v = The bot's current version" & vbNewLine & _ - "%a = Database access of the person who joins" & vbNewLine & _ - "%f = Database flags of the person who joins" & vbNewLine & _ - "%t = Current time" & vbNewLine & _ - "%d = Current date" + lblGreetVars.Caption = "Greet message variables:" & vbNewLine & _ + "%c or %chan = Current channel" & vbNewLine & _ + "%0 or %user = Username of the person who joins" & vbNewLine & _ + "%1 or %me = Bot's current username" & vbNewLine & _ + "%p or %ping = Ping of the person who joins" & vbNewLine & _ + "%v or %ver = The bot's current version" & vbNewLine & _ + "%a or %r = Database access / %f = Database flags of the person who joins" & vbNewLine & _ + "%m or %mail = Number of unread messages for the person who joins" & vbNewLine & _ + "%bc = Mumber of people the bot has banned" & vbNewLine & _ + "%t = Current time / %d = Current date" - lblIdleVars.Caption = "Idle message variables: (Suggest more! email stealth@stealthbot.net) " & vbNewLine & _ - "%c = Current channel" & vbNewLine & _ - "%me = Current username" & vbNewLine & _ - "%v = Bot version" & vbNewLine & _ - "%botup = Bot uptime" & vbNewLine & _ - "%cpuup = System uptime" & vbNewLine & _ + lblIdleVars.Caption = "Idle message variables:" & vbNewLine & _ + "%c or %chan = Current channel" & vbNewLine & _ + "%1 or %me = Current username" & vbNewLine & _ + "%v or %ver = Bot version" & vbNewLine & _ + "%botup = Bot uptime / %cpuup = System uptime" & vbNewLine & _ "%mp3 = Current MP3" & vbNewLine & _ "%quote = Random quote" & vbNewLine & _ - "%rnd = Random person in the channel" & vbNewLine + "%rnd = Random person in the channel" & vbNewLine & _ + "%bc = Mumber of people the bot has banned" & vbNewLine & _ + "%t = Current time / %d = Current date" '########################################## 'COLOR STUFF diff --git a/trunk/modOtherCode.bas b/trunk/modOtherCode.bas index 108824ee..36c5e4d9 100644 --- a/trunk/modOtherCode.bas +++ b/trunk/modOtherCode.bas @@ -1761,30 +1761,61 @@ Public Sub CaughtPhrase(ByVal Username As String, ByVal Msg As String, ByVal Phr End Sub -Public Function DoReplacements(ByVal s As String, Optional Username As String, _ - Optional Ping As Long) As String +Public Function DoReplacements(ByVal s As String, Optional ByVal Username As String, _ + Optional ByVal Ping As Long) As String Dim gAcc As udtUserAccess - - gAcc = Database.GetUserAccess(Username) + Dim Rank As Integer + + s = Replace(s, "%ver", CVERSION) + s = Replace(s, "%v", CVERSION) + s = Replace(s, "%botup", ConvertTimeInterval(GetConnectionUptime())) + s = Replace(s, "%cpuup", ConvertTimeInterval(GetTickCountMS())) + s = Replace(s, "%chan", g_Channel.Name) + s = Replace(s, "%c", g_Channel.Name) + s = Replace(s, "%me", GetCurrentUsername) + s = Replace(s, "%1", GetCurrentUsername) + s = Replace(s, "%rnd", GetRandomUserInChannel) + s = Replace(s, "%bc", BanCount) + s = Replace(s, "%mp3", Replace(MediaPlayer.TrackName, "&", "+")) + s = Replace(s, "%quote", g_Quotes.GetRandomQuote) + s = Replace(s, "%t", FormatDateTime(Now, vbLongTime)) + s = Replace(s, "%d", FormatDateTime(Now, vbShortDate)) + + If Not IsMissing(Username) Then + gAcc = Database.GetUserAccess(Username) + Rank = 0 + If gAcc.Rank > 0 Then Rank = gAcc.Rank + + s = Replace(s, "%user", Username) + s = Replace(s, "%u", Username) + s = Replace(s, "%0", Username) + If Not IsMissing(Ping) And Ping > -2 Then + s = Replace(s, "%p", Ping) + End If + s = Replace(s, "%a", Rank) + s = Replace(s, "%rank", Rank) + s = Replace(s, "%r", Rank) + s = Replace(s, "%flags", gAcc.Flags) + s = Replace(s, "%flag", gAcc.Flags) + s = Replace(s, "%f", gAcc.Flags) + s = Replace(s, "%mail", GetMailCount(Username)) + s = Replace(s, "%m", GetMailCount(Username)) + End If + + DoReplacements = s +End Function - s = Replace(s, "%0", Username, 1) - s = Replace(s, "%1", GetCurrentUsername, 1) - s = Replace(s, "%c", g_Channel.Name, 1) - s = Replace(s, "%bc", BanCount, 1) +Public Function GetRandomUserInChannel() As String + Dim i As Integer - If (Ping > -2) Then - s = Replace(s, "%p", Ping, 1) + If (g_Channel.Users.Count > 0) Then + Randomize + + i = Int(g_Channel.Users.Count * Rnd + 1) + + GetRandomUserInChannel = g_Channel.Users(i).DisplayName End If - - s = Replace(s, "%v", CVERSION, 1) - s = Replace(s, "%a", IIf(gAcc.Rank >= 0, gAcc.Rank, "0"), 1) - s = Replace(s, "%f", IIf(gAcc.Flags <> vbNullString, gAcc.Flags, ""), 1) - s = Replace(s, "%t", Time$, 1) - s = Replace(s, "%d", Date, 1) - s = Replace(s, "%m", GetMailCount(Username), 1) - - DoReplacements = s End Function Public Function ListFileLoad(ByVal sPath As String, Optional ByVal MaxItems As Integer = -1) As Collection