Skip to content
Permalink
Browse files

Greet and idle message variable replaces combined; fix labels on Sett…

…igns form

* As much as Stealth may love emails about his bot 15 years later,
  removed the "suggest more!" label from the Idle and Greet Settings
  panels - use the issue tracker on GitHub for suggestions now
* It now lists "%m" for greets, "%t" and "%d" for idles, and "%bc" for both
* Greet and Idle messages both use the same set of variables (where
  greet has an extra set that are user-specific)
* This implements "%botup", "%cpuup" for greets; "%d" for idles
* Fix "%ver" not working as an alias for "%v"
* "%t" now uses the "long time" FormatDateTime() and "%d" now uses the
  "short date" FormatDateTime() using the system's locale settings
  • Loading branch information...
nmbook committed Mar 21, 2017
1 parent 77a4fb6 commit 82c0dcc3524cfeec4600ba3878f970b5f452c25a
Showing with 69 additions and 60 deletions.
  1. +1 −24 trunk/frmChat.frm
  2. +18 −17 trunk/frmSettings.frm
  3. +50 −19 trunk/modOtherCode.bas
@@ -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

@@ -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
@@ -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, "<none>"), 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

0 comments on commit 82c0dcc

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