-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDefinition System.txt
85 lines (79 loc) · 2.81 KB
/
Definition System.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
Script("Name") = "Definitions"
Script("Author") = "Tuck"
Script("Major") = 1
Script("Minor") = 0
Script("Revision") = 0
Script("Description") = "Define System From 2.6R3"
Private dbPath
Sub Event_Load()
dbPath = BotPath() & "definitions.ini"
If (OpenCommand("define") Is Nothing) Then
With CreateCommand("define")
.Aliases.Add "def"
.RequiredRank = 60
.Parameters.Add .NewParameter("Term", False, "String")
.Save
End With
End If
If (OpenCommand("newdef") Is Nothing) Then
With CreateCommand("newdef")
.RequiredRank = 60
.Parameters.Add .NewParameter("String", False, "String")
.Save
End With
End If
If (OpenCommand("deldef") Is Nothing) Then
With CreateCommand("deldef")
.RequiredRank = 60
.Parameters.Add .NewParameter("Term", False, "String")
.Save
End With
End If
End Sub
Sub Event_Command(Command)
If (Not Command.HasAccess Or Not Command.IsValid) Then Exit Sub
If (Command.IsLocal And Not IsOnline()) Then Command.Username = BotVars.Username
Select Case LCase(Command.Name)
Case "define" : Def Command
Case "newdef" : NewDef Command
Case "deldef" : DelDef Command
End Select
End Sub
Private Sub Def(Command)
Definition = GetConfigEntry("Def", Command.Argument("Term"), dbPath)
If Len(Definition) > 0 Then
Response = "[ " & Command.Argument("Term") & " ]: " & Definition
Else
Response = "No definition on file for [ " & Command.Argument("Term") & " ]."
End If
Command.Respond(Response)
End Sub
Private Sub NewDef(Command)
If InStr(Command.Argument("String"), "|") > 0 Then
Term = Split(Command.Argument("String"), "|")(0)
If Len(Term) > 0 Then
Definition = Split(Command.Argument("String"), "|")(1)
If Len(Definition) > 0 Then
WriteConfigEntry "Def", Term, Definition, dbPath
Response = "Added definition for [ " & Term & " ]."
Else
Response = "You need to specify a definition."
End If
Else
Response = "You need to specify a term."
End If
Else
Response = "Error: Please format your definitions correctly. (" & BotVars.Trigger & Command.Name & " Term|Definition)"
End If
Command.Respond(Response)
End Sub
Private Sub DelDef(Command)
Definition = GetConfigEntry("Def", Command.Argument("Term"), dbPath)
If Len(Definition) > 0 Then
WriteConfigEntry "Def", Command.Argument("Term"), VbNullString, dbPath
Response = "Deleted definition for [ " & Command.Argument("Term") & " ]."
Else
Response = "No definition for [ " & Command.Argument("Term") & " ]."
End If
Command.Respond(Response)
End Sub