-
Notifications
You must be signed in to change notification settings - Fork 21
/
replies.go
232 lines (220 loc) · 10.6 KB
/
replies.go
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
package main
import (
"encoding/json"
"fmt"
"regexp"
"strings"
)
type Reply struct {
pattern string
unless string
message string
excludeChannels []string
excludeRoles []Role
onlyChannels []string
onlyRoles []Role
regex *regexp.Regexp
notRegex *regexp.Regexp
}
type currencyinfo struct {
Amount int64 `json:"premium_amount"`
DisplayName string `json:"display_name"`
Symbol string `json:"symbol"`
}
var nightlies = "https://impactclient.net/ImpactInstaller.<EXT>?nightlies=true"
var installer = "https://impactclient.net/download"
var replies = []Reply{
{
pattern: `faq|question|tutorial`,
message: "[Setup/Install FAQ](https://github.com/impactdevelopment/impactclient/wiki/Setup-FAQ)\n[Usage FAQ](https://github.com/impactdevelopment/impactclient/wiki/Usage-FAQ)",
},
{
pattern: `defender|virus|mcafee|norton|trojan|\brat\b`,
message: "[FAQ: My antivirus says the installer is a virus! Is it a virus?](https://github.com/ImpactDevelopment/ImpactIssues/wiki/Setup-FAQ#my-antivirus-says-the-installer-is-a-virus-is-it-a-virus)\n\n[Direct download link after AdFly](https://impactdevelopment.github.io/?brady-money-grubbing-completed=true)",
},
{
pattern: `tutorial|(impact|install|download).*(windows|linux|mac)`,
message: "Tutorial videos for downloading and installing the client:\n[Windows](https://www.youtube.com/watch?v=9IV_NC377pg)\n[macOS](https://www.youtube.com/watch?v=BBO0v4eq95k)\n[GNU/Linux](https://www.youtube.com/watch?v=XPLvooJeQEI)\n",
},
{
pattern: `baritone\s*setting`,
message: "[Baritone settings list and documentation](https://baritone.leijurv.com/baritone/api/Settings.html#field.detail)",
},
{
pattern: `screenshot`,
message: "[How to take a screenshot in Minecraft](https://www.minecraft.net/en-us/article/screenshotting-guide)",
},
{
pattern: `use\s*baritone|baritone\s*(usage|command)|[^u]\.b|goal|goto|path`,
message: "Please read the [Baritone usage guide](https://github.com/cabaletta/baritone/blob/master/USAGE.md)",
},
{ // Info for non-donators about donating
pattern: `premium|donat|become\s*a?\s+don(at)?or|what\s*do\s*(you|i|u)\s*(get|unlock)|perks?`,
// Unless it would be a better fit for another reply (e.g. not asking about premium)
unless: `(installe?r?|mediafire|dire(c|k)+to?\s+(linko?|url|site|page)|ad\s?f\.?ly|(ad|u)\s?block|download|ERR_CONNECTION_ABORTED|evassmat|update|infect)`,
message: "If you donate **<stripe_currency_list>** (or more), you will receive early access to upcoming releases through nightly builds when they are available (**now including 1.16.5 nightly builds!**), " +
"1 premium mod (Ignite), a cape visible to other Impact users, a gold colored name in the Impact Discord Server, and access to #donator-help (with faster and nicer responses). " +
"Go on the [website](https://impactclient.net/#donate) to donate. You will also need to [register](https://impactclient.net/register) your account and/or " +
"[login](https://impactclient.net/account) to get access to all the promised features",
excludeRoles: []Role{Donator},
},
{ // Installer download for non-donators (not asking about premium)
pattern: `installe?r?|mediafire|dire(c|k)+to?\s+(linko?|url|site|page)|ad\s?f\.?ly|(ad|u)\s?block|download|ERR_CONNECTION_ABORTED|evassmat|update|infect`,
// Unless it would be a better match for another reply (e.g. asking about premium, optifine or forge)
unless: `nightly|pre[- ]*release|beta|alpha|alfa|((download|get|where).*1[.]16)`,
excludeRoles: []Role{Donator},
message: "Download the installer [here](" + installer + ")",
},
{ // Installer download for donators
pattern: `installe?r?|mediafire|dire(c|k)+to?\s+(linko?|url|site|page)|ad\s?f\.?ly|(ad|u)\s?block|download|ERR_CONNECTION_ABORTED|evassmat|update|infect`,
onlyRoles: []Role{Donator},
message: "You can download the normal installer [here](" + installer + ").\n" +
"As a Donator, you can also install **nightly builds** of Impact: Download the Impact Nightly Installer [for Windows (.exe)](" + strings.Replace(nightlies, "<EXT>", "exe", 1) + ") or [for other platforms (.jar)](" + strings.Replace(nightlies, "<EXT>", "jar", 1) + ").\n" +
"You can also access these links by logging into your [Impact Account dashboard](https://impactclient.net/account)",
},
{ // Install info for optifine
pattern: `\b(install.*impact.*opti\s*fine)\b`,
message: "Use the [installer](" + installer + ") to add OptiFine to Impact: [Instructions](https://github.com/ImpactDevelopment/ImpactIssues/wiki/Adding-OptiFine)",
},
{ // Install info for Forge
pattern: `\b(install.*impact.*forge|support.*forge)\b`,
message: "Use the [installer](https://impactclient.net/) to install Forge (1.12.2 only)\nStandalone Baritone supports Forge on various versions - Download from [GitHub](https://github.com/cabaletta/baritone/releases).",
},
{ // Install info for LiteLoader
pattern: `lite\s*loader`,
message: "[LiteLoader tutorial](https://github.com/ImpactDevelopment/ImpactIssues/wiki/Adding-LiteLoader)",
},
{ // Links to Impactt website
pattern: `(web\s?)?(site|page)`,
message: "[Impact Website](https://impactclient.net)",
},
{ // GitHub repo for issues
pattern: `issue|bug|crash|error|suggest(ion)?s?|feature|enhancement`,
message: "Use the [GitHub repo](https://github.com/ImpactDevelopment/ImpactIssues/issues) to report issues/suggestions!",
},
{ // Non-donator help redirect
pattern: `help|support`,
message: "Switch to the <#" + help + "> channel!",
excludeRoles: []Role{Donator},
excludeChannels: []string{help, betterHelp},
},
{ // Donator help redirect
pattern: `help|support`,
message: "Switch to the <#" + betterHelp + "> channel!",
onlyRoles: []Role{Donator},
excludeChannels: []string{help, betterHelp},
},
{ // What does Franky do????
pattern: `what(\sdoes|\sis|s|'s)?\s+franky`,
message: "[It does exactly what you think it does.](https://youtu.be/_FzInOheiRw)",
},
{ // Information on macros
pattern: `macros?`,
message: "Macros are in-game chat commands, they can be accessed in-game by clicking on the Impact button, then Macros.",
},
{ // Links to the Impact changelogs
pattern: `change(\s*logs?|s)`,
message: "[Changelog](https://impactclient.net/changelog)",
},
{ // Notice about "hacking"
pattern: `hack(s|ing|er|client)?`,
message: "**Impact is not a hacked client**, it is designed as a utility mod (e.g. for anarchy servers).\nSupport will not be provided to users who utilise Impact on servers that do not allow it.\nPlease also note that the discussion of \"hacks\" in this Discord server is prohibited to comply with the [Discord Community Guidelines](https://discord.com/guidelines)",
},
{ // Weeb moment
pattern: `dumb|retard|idiot`,
message: "Like the " + Weeb.Mention() + "s?",
onlyRoles: []Role{Weeb},
},
{ // Info on using schematics
pattern: `schematics?`,
message: "Schematic file **MUST** be made in a 1.12.2 world or prior.\n1) Place the .schematic file into `.minecraft/schematics`.\n2) Ensure all the blocks are in your hotbar.\n3) Type `#build name.schematic`.",
},
{ // Info on using cracked launchers
pattern: `((crack|cracked) (launcher|account|game|minecraft))|(terramining|shiginima|(t(-|)launcher))`,
message: "Impact does not support cracked launchers. You can attempt to use the unstable Forge version, but no further support will be provided.",
},
{ // Link to the Impact wiki
pattern: `\b(impact\s*wiki|(setup|use)\s*spam(mer)?|faq)\b`,
message: "[Impact Wiki](https://github.com/ImpactDevelopment/ImpactIssues/wiki)",
},
{ // Downloads for JRE
pattern: `java.*(download|runtime|environment)`,
message: "[Downloads for Java Runtime Environment](https://www.java.com/download/)",
},
{ // How to use Impact's automine function
pattern: `how.+(mine|auto\s*mine)`,
message: "You can mine a specific type of block(s) by typing `#mine [number of blocks to mine] <ID> [<ID>]` in chat.\nYou can find a list of block ID names [here](https://www.digminecraft.com/lists/)",
},
{ // Older versions of Impact
pattern: `(impact.+(1\.8|1\.7))|((1\.8|1\.7).impact)`,
message: "Impact for older versions is no longer availible to comply with Mojang's EULA.",
},
{ // Information on using Impact with modpacks
pattern: `(modpack|\bftb\b|rlcraft|skyfactory|valhelsia|pixelmon|sevtech)`,
message: "Impact is generally incompatible with modpacks and support will not be provided if you encounter bugs with them. It's likely your game will just crash on startup.",
},
{
pattern: `good\s*bot`,
message: "tnyak yow *nuwzzwes yoww necky wecky*",
},
{
pattern: `((anti(-|\s*)(kb|knockback))|velocity)`,
message: "**Velocity**, also known as **Anti-knockback**, is a module under \"Movement\" that prevents the player from taking knockback.",
},
{
pattern: `(gui|r(-|\s)shift|module|(open|close|show|hide)\s*impact)`,
message: "To open or close the Impact GUI, press the `rshift` key, located below `enter`.",
},
}
func init() {
// Fetch stripe info from Impact API, since we need to know how much users need to donate for premium
amountPattern := regexp.MustCompile(`<stripe_currency_list>`)
amountList := "<error fetching currency info>"
currencies, err := getCurrencyInfo()
if err != nil {
println("Error getting Stripe info from Impact API: " + err.Error())
} else {
amountList = getCurrencyAmountString(currencies)
}
// Compile all the regex patterns, and replace any template strings
for i := range replies {
replies[i].regex = regexp.MustCompile(replies[i].pattern)
if replies[i].unless != "" {
replies[i].notRegex = regexp.MustCompile(replies[i].unless)
}
if amountPattern.MatchString(replies[i].message) {
replies[i].message = amountPattern.ReplaceAllLiteralString(replies[i].message, amountList)
}
}
}
func getCurrencyAmountString(currencies map[string]currencyinfo) string {
const separator = ", "
var currencyList = ""
for id, currency := range currencies {
if currencyList != "" {
currencyList += separator
}
var amount float64
amount = float64(currency.Amount) / 100
currencyList += fmt.Sprintf("%s%0.2f %s", currency.Symbol, amount, strings.ToUpper(id))
}
index := strings.LastIndex(currencyList, separator)
if index > -1 {
currencyList = currencyList[0:index] + " or " + currencyList[index+len(separator):]
}
return currencyList
}
func getCurrencyInfo() (map[string]currencyinfo, error) {
str, err := get("https://api.impactclient.net/v1/stripe/info")
if err != nil {
return nil, err
}
var info struct {
Currencies map[string]currencyinfo `json:"currencies"`
}
err = json.Unmarshal([]byte(str), &info)
if err != nil {
return nil, err
}
return info.Currencies, nil
}