First commit
This commit is contained in:
commit
f69721f642
10 changed files with 151 additions and 0 deletions
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
.DS_Store
|
||||||
|
.idea
|
||||||
|
*.log
|
||||||
|
tmp/
|
||||||
|
|
||||||
|
|
||||||
|
src/apikey.nim
|
||||||
|
boardsourcebot
|
2
Dockerfile
Normal file
2
Dockerfile
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
FROM nimlang/nim:onbuild
|
||||||
|
ENTRYPOINT ["./boardsourcebot"]
|
35
Makefile
Normal file
35
Makefile
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
##
|
||||||
|
# Discord bot for boardsource
|
||||||
|
#
|
||||||
|
# @file
|
||||||
|
# @version 0.1
|
||||||
|
|
||||||
|
SRC = boardsourcebot.nim
|
||||||
|
SRCDIR = src
|
||||||
|
BIN = boardsourcebot
|
||||||
|
SERVICE_FILE = boardsourcebot.service
|
||||||
|
INSTALL_DIR = /opt/boardsourcebot
|
||||||
|
SERVICE_DIR = /usr/lib/systemd/system/
|
||||||
|
|
||||||
|
debug:
|
||||||
|
nimble build '-d:ssl --cc:clang'
|
||||||
|
|
||||||
|
release:
|
||||||
|
nimble build '-d:ssl --cc:clang -d:release'
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f ./${BIN}
|
||||||
|
|
||||||
|
pretty:
|
||||||
|
nimpretty ${SRCDIR}/${SRC}
|
||||||
|
|
||||||
|
run:
|
||||||
|
./${BIN}
|
||||||
|
|
||||||
|
install:
|
||||||
|
mkdir -P /opt/${INSTALL_DIR}
|
||||||
|
cp ./${BIN} /opt/${INSTALL_DIR}/${BIN}
|
||||||
|
cp ${SERVICE_FILE} ${SERVICE_DIR}/${SERVICE_FILE}
|
||||||
|
|
||||||
|
|
||||||
|
# end
|
9
README.md
Normal file
9
README.md
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# Boardsource bot
|
||||||
|
Boardsourcebot is designed to make the lives or the boardsource mods easier to help deal with repeat questions
|
||||||
|
|
||||||
|
## Requirementss
|
||||||
|
1. Install Nim using [choosenim](https://github.com/dom96/choosenim) or [Nim's website](https://nim-lang.org/install.html)
|
||||||
|
2. Install Nimble from [numble](https://github.com/nim-lang/nimble)
|
||||||
|
|
||||||
|
##Building
|
||||||
|
`make release` or `make debug`
|
14
boardsourcebot.nimble
Normal file
14
boardsourcebot.nimble
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# Package
|
||||||
|
|
||||||
|
version = "0.1.0"
|
||||||
|
author = "Kyle Brown"
|
||||||
|
description = "Boardsource discord bot"
|
||||||
|
license = "MIT"
|
||||||
|
srcDir = "src"
|
||||||
|
bin = @["boardsourcebot"]
|
||||||
|
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
|
|
||||||
|
requires "nim >= 1.4.6"
|
||||||
|
requires "dimscord >= 1.2.5"
|
9
boardsourcebot.service
Executable file
9
boardsourcebot.service
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
[Unit]
|
||||||
|
Description=boardsourcebot
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
WorkingDirectory=/opt/boardsourcebot
|
||||||
|
ExecStart=/opt/boardsourcebot/boardsourcebot
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
4
dockerrun.sh
Executable file
4
dockerrun.sh
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
docker build -t boardsourcebot .
|
||||||
|
docker run --rm boardsourcebot
|
1
nim.cfg
Normal file
1
nim.cfg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
-d:ssl
|
2
src/apikey.nim.example
Normal file
2
src/apikey.nim.example
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
const prefix = "!"
|
||||||
|
const apikey = ""
|
67
src/boardsourcebot.nim
Normal file
67
src/boardsourcebot.nim
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
include apikey
|
||||||
|
import dimscord, asyncdispatch, options, strformat, strutils
|
||||||
|
|
||||||
|
let discord = newDiscordClient(apikey)
|
||||||
|
|
||||||
|
# Handle event for on_ready.
|
||||||
|
proc onReady(s: Shard, r: Ready) {.event(discord).} =
|
||||||
|
echo "Ready as " & $r.user
|
||||||
|
|
||||||
|
# Handle event for message_create.
|
||||||
|
proc messageCreate(s: Shard, m: Message) {.event(discord).} =
|
||||||
|
if m.author.bot: return
|
||||||
|
|
||||||
|
if m.content == fmt"{prefix}help":
|
||||||
|
let msg = await discord.api.sendMessage(m.channel_id,
|
||||||
|
fmt"""
|
||||||
|
Commands are prefixed with {prefix}. Avaliable commands are help, brokenkey,
|
||||||
|
buildguide, trrs, restock, shipping, oled, configure, elitec, sockets
|
||||||
|
""".dedent.splitlines.join(" "))
|
||||||
|
|
||||||
|
elif m.content == fmt"{prefix}brokenkey":
|
||||||
|
let msg = await discord.api.sendMessage(m.channel_id, "Broken key tips can be found here")
|
||||||
|
let link = await discord.api.sendMessage(m.channel_id,
|
||||||
|
"https://discord.com/channels/704394060390989834/705657159639105626/798051589004197938")
|
||||||
|
|
||||||
|
elif m.content == fmt"{prefix}buildguide":
|
||||||
|
let msg = await discord.api.sendMessage(m.channel_id, "Build guides can be found here")
|
||||||
|
let link = await discord.api.sendMessage(m.channel_id,
|
||||||
|
"https://discord.com/channels/704394060390989834/705657159639105626/790728181857910854")
|
||||||
|
|
||||||
|
elif m.content == fmt"{prefix}trrs":
|
||||||
|
let msg = await discord.api.sendMessage(m.channel_id, "TRRS jacks are included with the PCB, as are the reset buttons")
|
||||||
|
|
||||||
|
elif m.content == fmt"{prefix}restock" or m.content ==
|
||||||
|
fmt"{prefix}shipping":
|
||||||
|
let gif = await discord.api.sendMessage(m.channel_id,
|
||||||
|
"https://media1.tenor.com/images/28cf6532c043be996d04c00ec2ac3246/tenor.gif?itemid=2088319")
|
||||||
|
let msg = await discord.api.sendMessage(m.channel_id,
|
||||||
|
"Shipping is backup up worldwide and we can not give estimates at the current time")
|
||||||
|
|
||||||
|
elif m.content == fmt"{prefix}oled":
|
||||||
|
let msg = await discord.api.sendMessage(m.channel_id, "OLED help can be found here")
|
||||||
|
let link = await discord.api.sendMessage(m.channel_id,
|
||||||
|
"https://discord.com/channels/704394060390989834/755980550539313293/790417018822197289")
|
||||||
|
|
||||||
|
elif m.content == fmt"{prefix}configure":
|
||||||
|
let msg = await discord.api.sendMessage(m.channel_id,
|
||||||
|
"""
|
||||||
|
Hitting configure will add at least one of each item you NEED For a working
|
||||||
|
keyboard, not including switches or keycaps. For example, it will include 1
|
||||||
|
PCB or pair of PCBs for splits. You may want to add or change items to
|
||||||
|
customize it for your needs or desires though!
|
||||||
|
""".dedent.splitlines.join(" "))
|
||||||
|
|
||||||
|
elif m.content == fmt"{prefix}elitec":
|
||||||
|
let msg = await discord.api.sendMessage(m.channel_id,
|
||||||
|
"""
|
||||||
|
The elite C uses a type-C port as opposed to microUSB making it less prone
|
||||||
|
to breaking, as well as having a better bootloader, which is especially
|
||||||
|
important for linux users.
|
||||||
|
""".dedent.splitlines.join(" "))
|
||||||
|
|
||||||
|
elif m.content == fmt"{prefix}sockets":
|
||||||
|
let msg = await discord.api.sendMessage(m.channel_id, "Socket information and links can be found here")
|
||||||
|
let link = await discord.api.sendMessage(m.channel_id, "https://discord.com/channels/704394060390989834/705657159639105626/752342450047156245")
|
||||||
|
|
||||||
|
waitFor discord.startSession()
|
Loading…
Add table
Reference in a new issue