In the world of Tech Support, we often find ourselves answering the same questions over and over again. Programmers don't like repetition of course, so here is my solution:
- Detect if a message is a question
- Scrub the question for keywords
- Match those keywords up to a common question
- Reply automatically with good information
As of the time of writing, there is only direct support for Discord and Console applications, but with a bit of tweaking you could implement this for whatever you need.
If you are not using gradle, then you'll have to add the dependency manually. If you
are using gradle, you're going to need a GitHub Token.
It will need permission to read:packages
(No other permissions are needed!):
- write:packages
- read:packages
Create a gradle.properties
file under your root project directory. Replace the placeholders
with your values.
user=Github Username
pass=Generated Token
Add the following to your build.gradle.kts
file.
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/CJCrafter/AutoSupport")
credentials {
username = findProperty("user").toString()
password = findProperty("pass").toString()
}
}
}
dependencies {
implementation("me.cjcrafter:autosupport:1.0.1")
}
Check out my YouTube video for a more in-depth explanation.
{
"Question": "How to tie a tie?",
"Activator": "<QUESTION,ALWAYS>",
"Only_Unverified": false,
"Channel_Whitelist": true,
"Channels": [
"YOUR CHANNEL ID"
],
"Delete_After_Answer": false,
"Keys": [
"key,key2,key3:-1",
"craft:1",
"recipe:1"
],
"Key_Threshold": 1,
"Message": [
"In order to add crafting recipes to your weapons, please check out our [tutorial](https://www.youtube.com/watch?v=OUhRLyh1mAg)",
"\n",
"\nOr check out [the wiki](https://github.com/WeaponMechanics/MechanicsMain/wiki/General#recipe)"
],
"Media": "imgur.link/whatever-i-am-not-googling-an-actual-image",
"Button": {
"Text": "Crafting Tutorial",
"Link": "https://github.com/WeaponMechanics/MechanicsMain/wiki/General#recipe"
}
}
This is what the bot thinks the user said. For example, if you're creating an auto-support for
how to add crafting recipes, you should use something like "How do add crafting recipes to items?"
.
Question
: Only respond to messages that are questions.Always
: Always try to respond to a message.- You can add more options by contributing.
true -> message is only sent to users without the verification role false -> message is sent to anyone
true -> only check channels in the Channels
list
false -> only check channels NOT in the Channels
list
The long
id of the channel(s). Right-click on your channel in discord and press Copy ID
.
For example: "1014360547971584131"
YES. IT IS A STRING. NOT A NUMBER.
true -> If the user pressed :check:, then their question will be deleted (since it was answered) in 30 minutes. false -> The question/answer stay in the channel no matter what.
Use true
if you are picky about message spam in your channel. Use false
to avoid any confusions.
The user can delete the message no matter what by pressing ❌
Ok, this is the important stuff. When a message is searched, it calls question.contains(key)
for each key. If that returns true
, then the value
will be added to the total.
If total >= threshold
, then the bot answers with this answer.
Format is: key1,key2,maybe even a full sentence:value
Any key stored in the SAME LINE as other keys won't get checked multiple times... So for example
"Keys": [
"explosion:2",
"block:1",
"come back,reappear,regen:1"
]
Here are the total
s for each message:
How do I create an EXPLOSION?
-> 2
How can I break blocks?
-> 1
After the blocks break, can I make them come back?
-> 2
Can they come back? You know... like regenerate?
-> 1
^ Used with Keys
. How big does total
need to be before this message is sent?
The actual response. Since this is an embed, it supports markdown formatting, like
- links
- bold
NO, WE DON'T ADD NEW LINES AUTOMATICALLY. DO IT YOURSELF.
NO, DISCORD EMBEDS DON'T SUPPORT IMAGES. SEE THE Media
OPTION
In order to use channels, use <#channel_id>
(users would be <@user_id>
)... This is
discord formatting stuff.
Includes the image at the given URL at the bottom of the embed. Cannot be a video, only a thumbnail.
Just a custom button that users can push... Usually to your wiki, but it would be hilarious if you sent them to a rick roll video.