Posted by: Vector
« on: December 16, 2008, 08:16:58 AM »Lol. Use what you did in the AM plugin to exit the sub if the user is safelisted as an example of what you need to do here. Its pretty much the same thing just about.
'GD
'4.3
'&Greet Delay Safelist:Hero (Edit by Shadow)
'*
'*
'*
'*
'*StealthBot Enhancement
'// Added UserTalk sub ~Vector
Public gd_Message
'// The greet message has been moved to a settings file and can now be edited by using a command
'// %% Variables %%
'// %u = User
'// %t = Time
'// %d = Date
'// %pi = Ping
'// %pr = Product
'// %ch = Current Channel
'// %ho = Home Channel
'// %ct = User's clan tag
'// %l = Level
'// %an = Numerical Access
'// %af = Flagged Access
'// %cc = Amount of people in the channel
'// %nl = Newline - Will start a second message
'// Default access to set the greet
Const gd_acc = 90
Const gd_Delay = 15
'// Delay in seconds
'// Ex. gd_Delay = 15
'// A greet will be sent every 15 seconds instead of instantly
Const gd_Between = 30
'// Time between joins by the same person to not greet with, in minutes
'// Ex. gd_Between = 30
'// Each user will only be greet once every 50 minutes
Const gd_NoClan = "NONE"
'// What to replace clan tag with if they are in no clan.
Const gd_NoIcon = "None"
'// What to replace icon with if they have no icon
'/// /// /// /// /// /// /// ///
'/// The script starts here ////
'/// /// /// /// /// /// /// ///
Public gd_GreetDic, gd_j, gd_TimeDic
Set gd_GreetDic = CreateObject("Scripting.Dictionary")
Set gd_TimeDic = CreateObject("Scripting.Dictionary")
Public dblTab
dblTab = vbTab & vbTab & vbTab
Sub gd_Event_Load
AddChat vbYellow, "Loading GD..."
TimerInterval "gd", "Greet", CInt(gd_Delay)
TimerEnabled "gd", "Greet", True
AddChat vbYellow, "Checking if your built-in greet is enabled..."
If GetConfigEntry("Other", "UseGreets", "config.ini") = "Y" Then
AddChat vbRed, "Your built-in greet message is enabled!"
AddChat vbYellow, "Disabling..."
Command BotVars.Username, "/greet off", True
AddChat vbGreen, "Disabled!"
Else
AddChat vbGreen, "Your built-in greet messages are disabled!"
End If
AddChat vbYellow, "Retrieving settings..."
If GetConfigEntry("Main", "Running", "GD.Settings.ini") = vbNullString Then
Call gd_WriteDefaultSettings
AddChat vbGreen, "Created settings file and wrote default settings!"
End If
gd_Message = GetConfigEntry("Main", "Greet Message", "GD.Settings.ini")
AddChat vbGreen, "Retrieved!"
AddChat vbGreen, "Greet Delay by Hero loaded!"
WriteConfigEntry "Main", "Running", "True", "GD.Settings.ini"
End Sub
Sub gd_Event_Close
AddChat vbYellow, "GD Saving settings..."
WriteConfigEntry "Main", "Greet Message", gd_Message, "GD.Settings.ini"
WriteConfigEntry "Main", "Running", "False", "GD.Settings.ini"
AddChat vbGreen, "Saved!"
End Sub
Sub gd_Event_PressedEnter(Text)
If Not Left(LCase(Text), 4) = "/gd " Then Exit Sub
Arg = Split(Trim(Mid(Text, 2)))
Select Case LCase(Arg(1))
Case "setgreet"
If UBound(Arg) < 2 Then
AddChat vbRed, "You must specify a new greet message"
AddChat vbYellow, "Your current greet message is: " & vbNewLine & dblTab & gd_Message
Else
For i = 2 To UBound(Arg)
newMessage = newMessage & Arg(i) & " "
Next
newMessage = Trim(newMessage)
gd_Message = newMessage
AddChat vbGreen, "New greet message set."
End If
VetoThisMessage
Case "greet"
If UBound(Arg) < 2 Then
AddChat vbGreen, "Your current greet message is: " & vbNewLine & dblTab & gd_Message
Else
For i = 2 To UBound(Arg)
newMessage = newMessage & Arg(i) & " "
Next
newMessage = Trim(newMessage)
gd_Message = newMessage
AddChat vbGreen, "New greet message set."
End If
VetoThisMessage
Case "var", "variables"
strVariables = "GD Variables: " & vbNewline _
& dblTab & "%u = User" & vbNewLine _
& dblTab & "%t = Time" & vbNewLine _
& dblTab & "%d = Date" & vbNewLine _
& dblTab & "%pi = Ping" & vbNewLine _
& dblTab & "%pr = Product" & vbNewLine _
& dblTab & "%ch = Current Channel" & vbNewLine _
& dblTab & "%ho = Home Channel" & vbNewLine _
& dblTab & "%ct = User's clan tag" & vbNewLine _
& dblTab & "%l = Level" & vbNewLine _
& dblTab & "%an = Numerical Access" & vbNewLine _
& dblTab & "%af = Flagged Access" & vbNewLine _
& dblTab & "%cc = Amount of people in the channel" & vbNewLine _
& dblTab & "%nl = Newline - Will start a second message"
AddChat vbGreen, strVariables
VetoThisMessage
Case "cmds", "commands"
strCommands = "GD Commands: " & vbNewLine _
& dblTab & "/gd setgreet " & vbNewLine _
& dblTab & " - Changes the GD greet message" & vbNewLine _
& dblTab & "/gd greet" & vbNewLine _
& dblTab & " - Says you current greet message" & vbNewLine _
& dblTab & "/gd var or /gd variables" & vbNewLine _
& dblTab & " - Tells you all of the current greet message variables" ' & vbNewLine _
' & dblTab & "/gd restore yes" & vbNewLine _
' & dblTab & " - Will restore the default settings"
AddChat vbGreen, strCommands
VetoThisMessage
End Select
End Sub
Sub gd_Event_UserTalk(Username, Flags, Message, Ping)
If Left(Message, Len(BotVars.Trigger)) <> BotVars.Trigger Then Exit Sub
GetDBEntry Username, a, f
If a < gd_acc Then Exit Sub
Arg = Split(Trim(Mid(Message, Len(BotVars.Trigger) + 1)))
If Not Lcase(Arg(0)) = "gd" Then Exit Sub
Select Case LCase(Arg(1))
Case "setgreet", "greet"
If UBound(Arg) < 2 Then
AddQ "You must specify a new greet message"
AddQ "Your current greet message is: " & gd_Message
Else
For i = 2 To UBound(Arg)
newMessage = newMessage & Arg(i) & " "
Next
newMessage = Trim(newMessage)
gd_Message = newMessage
AddQ "New greet message set."
End If
VetoThisMessage
End Select
End Sub
Sub gd_Event_Userjoins(Username, Flags, Message, Ping, Product, Level, OriginalStatString, Banned)
If GetInternalDataByUsername(Username, 2) = 32 Then Exit Sub
If IsSafelisted(Username) Then Exit Sub
GetDBEntry Username, Access, Flags
If myFlags = "S" or myFlags = "s" Then Exit Sub
Msg = gd_ParseMessage(Username, Flags, Message, Ping, Product, Level, OriginalStatString)
gd_GreetDic.Item(Username) = Msg
End Sub
Sub gd_Greet_Timer()
If Not gd_GreetDic.Count = 0 Then
For Each user In gd_GreetDic.Keys
If gd_TimeDic.Exists(user) Then
Last = gd_TimeDic.Item(user)
Else
Last = Now()
End If
Current = Now()
Difference = DateDiff("S", Last, Current)
If gd_UserInChannel(user) Then
If Difference >= CInt(gd_Between * 60) OR Difference = 0 Then
gd_TimeDic.Item(user) = Current
Messages = gd_GreetDic.Item(user)
For i = 0 To UBound(Messages)
Dsp 3, Trim(Messages(i)), user, vbGreen
Next
End If
gd_GreetDic.Remove(user)
Exit For
End If
Next
End If
End Sub
Function gd_UserInChannel(User)
Found = False
For i = 0 To GetInternalUserCount
If LCase(GetNameByPosition(i)) = LCase(User) Then
Found = True
End If
Next
gd_UserInChannel = Found
End Function
Function gd_ParseMessage(Username, Flags, Message, Ping, Product, Level, OriginalStatString)
On Error Resume Next
GetDBEntry Username, uNum, uFlags
ClanTag = GetInternalDataByUsername(Username, 0)
If ClanTag = vbNullString Then ClanTag = gd_NoClan
If uNum = -1 Then uNum = 0
If uFlags = vbNullString Then uFlags = "none"
StatString = ReverseString(OriginalStatString)
sStatString = Split(StatString)
If InStr(Product, "3") > 0 AND UBound(sStatString) > 0 AND InStr(gd_Message, "%ico") > 0 Then
For i = 0 To UBound(sStatString)
If sStatString(i) = Product Then
IconInfo = sStatString(i - 1)
End If
Next
If IconInfo = "WCPG" Then
Icon = "WCG ProGamer"
Else
IconRaceShort = Array("H", "U", "R", "O", "N", "T")
IconRaceLong = Array("Human", "Undead", "Random", "Orc", "Night Elf", "Tournament")
IconRace = Mid(IconInfo, 3, 1)
For i = 0 To UBound(IconRaceShort)
If IconRace = IconRaceShort(i) Then
IconRace = IconRaceLong(i)
Exit For
End If
Next
If Not InArray(IconRaceLong, IconRace) Then IconRace = "Unknown"
IconName = Mid(IconInfo, 4, 1)
IconNameShort = Array(1, 2, 3, 4, 5, 6)
IconNameLong = CreateRacialIconArray(IconRace)
For i = 0 To UBound(IconNameShort)
If CInt(IconName) = IconNameShort(i) Then
IconName = IconNameLong(i)
Exit For
End If
Next
Icon = IconRace & " - " & IconName
End If
Else
Icon = gd_NoIcon
End If
Msg = Replace(gd_Message, "%u", Username)
Msg = Replace(Msg, "%pi", Ping)
Msg = Replace(Msg, "%pr", Product)
Msg = Replace(Msg, "%l", Level)
Msg = Replace(Msg, "%d", Date)
Msg = Replace(Msg, "%t", Time)
Msg = Replace(Msg, "%an", uNum)
Msg = Replace(Msg, "%af", uFlags)
Msg = Replace(Msg, "%ch", myChannel)
Msg = Replace(Msg, "%ct", ClanTag)
Msg = Replace(Msg, "%ho", GetConfigEntry("Main", "HomeChan", "config.ini"))
Msg = Replace(Msg, "%cc", GetInternalUserCount)
Msg = Replace(Msg, "%ico", Icon)
Msg = Split(Msg, "%nl")
gd_ParseMessage = Msg
If Err.Number <> 0 THen
AddChat vbRed, Err.Source
AddChat vbRed, Err.Description
AddChat vbRed, "Statstring: " & StatString
AddChat vbRed, "Msg: " & Msg
AddChat vbRed, "Icon Info: " & IconInfo
End If
End Function
Sub gd_WriteDefaultSettings
WriteConfigEntry "Main", "Greet Message", "[GD] This is an automated message notifying you that you are NOT safelisted.", "GD.Settings.ini"
WriteConfigEntry "Variables", "%u", "User", "GD.Settings.ini"
WriteConfigEntry "Variables", "%t", "Time", "GD.Settings.ini"
WriteConfigEntry "Variables", "%d", "Date", "GD.Settings.ini"
WriteConfigEntry "Variables", "%pi", "Ping", "GD.Settings.ini"
WriteConfigEntry "Variables", "%pr", "Product", "GD.Settings.ini"
WriteConfigEntry "Variables", "%ch", "Current Channel", "GD.Settings.ini"
WriteConfigEntry "Variables", "%ho", "Home Channel", "GD.Settings.ini"
WriteConfigEntry "Variables", "%ct", "User's clan tag", "GD.Settings.ini"
WriteConfigEntry "Variables", "%l", "Level", "GD.Settings.ini"
WriteConfigEntry "Variables", "%an", "Numerical Access", "GD.Settings.ini"
WriteConfigEntry "Variables", "%af", "Flagged Access", "GD.Settings.ini"
WriteConfigEntry "Variables", "%cc", "Amount of people in the channel", "GD.Settings.ini"
WriteConfigEntry "Variables", "%nl", "Newline - Will start a second message", "GD.Settings.ini"
End Sub
Function ReverseString(Str)
For i = 0 To Len(Str)
If i <> Len(Str) Then nStr = nStr & Mid(Str, Len(Str) - i, 1)
Next
ReverseString = nStr
End Function
Function CreateRacialIconArray(Race)
Select Case Race
Case "Human"
arrLong = Array("Peon", "Rifleman", "Sorceress", "Spellbreaker", "Bloodmage", "Jiana")
Case "Undead"
arrLong = Array("Peon", "Crpyt Fiend", "Banshee", "Destroyer", "Crypt Lord", "Sylvanas")
Case "Random"
arrLong = Array("Peon", "Myrmidon", "Siren", "Dragon Turtle", "Sea Witch", "Illidan")
Case "Orc"
arrLong = Array("Peon", "Troll Headhunter", "Shaman", "Spirit Walker", "Shadow Hunter", "Rexxar")
Case "Night Elf", "Night Elves"
arrLong = Array("Peon", "Huntress", "Druid of the Talon", "Dryad", "Keeper of the Grove", "Maiev")
Case "Tournament", "Unknown"
arrLong = Array("Peon", "Felguard", "Infernal", "Doomguard", "Pit Lord", "Archimonde")
End Select
CreateRacialIconArray = arrLong
End Function
Function InArray(Arr, Item)
If Not IsArray(Arr) Then
InArray = False
Else
Found = False
For i = LBound(Arr) To UBOund(Arr)
If LCase(Arr(i)) = LCase(Item) Then
Found = True
End If
Next
InArray = Found
End If
End Function