mirror of
https://github.com/jackmerrill/hampbot.git
synced 2024-12-04 13:02:59 -08:00
initial commit 🎉
This commit is contained in:
commit
8e6ed1e9ce
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
.env
|
||||||
|
__debug_bin.*
|
||||||
|
__debug_bin
|
62
.vscode/hampbot-snippets.code-snippets
vendored
Normal file
62
.vscode/hampbot-snippets.code-snippets
vendored
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
{
|
||||||
|
// Place your hampbot workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
|
||||||
|
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
|
||||||
|
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
|
||||||
|
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
|
||||||
|
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
|
||||||
|
// Placeholders with the same ids are connected.
|
||||||
|
// Example:
|
||||||
|
// "Print to console": {
|
||||||
|
// "scope": "javascript,typescript",
|
||||||
|
// "prefix": "log",
|
||||||
|
// "body": [
|
||||||
|
// "console.log('$1');",
|
||||||
|
// "$2"
|
||||||
|
// ],
|
||||||
|
// "description": "Log output to console"
|
||||||
|
// }
|
||||||
|
"Command": {
|
||||||
|
"prefix": "command",
|
||||||
|
"body": [
|
||||||
|
"import (",
|
||||||
|
" \"github.com/jackmerrill/hampbot/internal/utils/config\"",
|
||||||
|
" \"github.com/zekroTJA/shireikan\"",
|
||||||
|
")",
|
||||||
|
"",
|
||||||
|
"type ${1:CommandName} struct {",
|
||||||
|
"}",
|
||||||
|
"",
|
||||||
|
"func (c *${1:CommandName}) GetInvokes() []string {",
|
||||||
|
" return []string{\"${1}\"}",
|
||||||
|
"}",
|
||||||
|
"",
|
||||||
|
"func (c *${1:CommandName}) GetDescription() string {",
|
||||||
|
" return \"${1:CommandName} description\"",
|
||||||
|
"}",
|
||||||
|
"",
|
||||||
|
"func (c *${1:CommandName}) GetHelp() string {",
|
||||||
|
" return \"`${1}` - `${1}`\"",
|
||||||
|
"}",
|
||||||
|
"",
|
||||||
|
"func (c *${1:CommandName}) GetGroup() string {",
|
||||||
|
" return config.GroupUtil",
|
||||||
|
"}",
|
||||||
|
"",
|
||||||
|
"func (c *${1:CommandName}) GetDomainName() string {",
|
||||||
|
" return \"hamp.util.${1}\"",
|
||||||
|
"}",
|
||||||
|
"",
|
||||||
|
"func (c *${1:CommandName}) GetSubPermissionRules() []shireikan.SubPermission {",
|
||||||
|
" return nil",
|
||||||
|
"}",
|
||||||
|
"func (c *${1:CommandName}) IsExecutableInDMChannels() bool {",
|
||||||
|
" return true",
|
||||||
|
"}",
|
||||||
|
"",
|
||||||
|
"func (c *${1:CommandName}) Exec(ctx shireikan.Context) error {",
|
||||||
|
" return nil",
|
||||||
|
"}"
|
||||||
|
],
|
||||||
|
"description": "Create a new command"
|
||||||
|
}
|
||||||
|
}
|
20
.vscode/launch.json
vendored
Normal file
20
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Launch Package",
|
||||||
|
"type": "go",
|
||||||
|
"request": "launch",
|
||||||
|
"mode": "auto",
|
||||||
|
"program": "main.go",
|
||||||
|
"envFile": "${workspaceFolder}/.env",
|
||||||
|
"args": [
|
||||||
|
"-ldflags",
|
||||||
|
"\"-X github.com/jackmerrill/hampbot/internal/utils/config.Version=dev -X github.com/jackmerrill/hampbot/internal/utils/config.Build=$(date -u +.%Y%m%d.%H%M%S)\""
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
37
go.mod
Normal file
37
go.mod
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
module github.com/jackmerrill/hampbot
|
||||||
|
|
||||||
|
go 1.19
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/PuerkitoBio/goquery v1.8.1 // indirect
|
||||||
|
github.com/andybalholm/cascadia v1.3.1 // indirect
|
||||||
|
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
|
||||||
|
github.com/bwmarrin/discordgo v0.27.1 // indirect
|
||||||
|
github.com/cespare/xxhash/v2 v2.1.1 // indirect
|
||||||
|
github.com/charmbracelet/lipgloss v0.7.1 // indirect
|
||||||
|
github.com/charmbracelet/log v0.2.3 // indirect
|
||||||
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||||
|
github.com/go-logfmt/logfmt v0.6.0 // indirect
|
||||||
|
github.com/go-redis/redis/v8 v8.11.0 // indirect
|
||||||
|
github.com/gorilla/websocket v1.5.0 // indirect
|
||||||
|
github.com/jackmerrill/hamp-api v0.0.0-20230818235104-8d222c9674c9 // indirect
|
||||||
|
github.com/labstack/echo/v4 v4.9.1 // indirect
|
||||||
|
github.com/labstack/gommon v0.4.0 // indirect
|
||||||
|
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||||
|
github.com/mattn/go-colorable v0.1.11 // indirect
|
||||||
|
github.com/mattn/go-isatty v0.0.18 // indirect
|
||||||
|
github.com/mattn/go-runewidth v0.0.14 // indirect
|
||||||
|
github.com/muesli/reflow v0.3.0 // indirect
|
||||||
|
github.com/muesli/termenv v0.15.2 // indirect
|
||||||
|
github.com/rivo/uniseg v0.2.0 // indirect
|
||||||
|
github.com/sarulabs/di/v2 v2.4.2 // indirect
|
||||||
|
github.com/sashabaranov/go-openai v1.14.2 // indirect
|
||||||
|
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||||
|
github.com/valyala/fasttemplate v1.2.1 // indirect
|
||||||
|
github.com/zekroTJA/shireikan v0.7.0 // indirect
|
||||||
|
github.com/zekrotja/dgrs v0.3.1 // indirect
|
||||||
|
golang.org/x/crypto v0.12.0 // indirect
|
||||||
|
golang.org/x/net v0.10.0 // indirect
|
||||||
|
golang.org/x/sys v0.11.0 // indirect
|
||||||
|
golang.org/x/text v0.12.0 // indirect
|
||||||
|
)
|
195
go.sum
Normal file
195
go.sum
Normal file
|
@ -0,0 +1,195 @@
|
||||||
|
github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM=
|
||||||
|
github.com/PuerkitoBio/goquery v1.8.1/go.mod h1:Q8ICL1kNUJ2sXGoAhPGUdYDJvgQgHzJsnnd3H7Ho5jQ=
|
||||||
|
github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c=
|
||||||
|
github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
|
||||||
|
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
|
||||||
|
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
|
||||||
|
github.com/bwmarrin/discordgo v0.23.2 h1:BzrtTktixGHIu9Tt7dEE6diysEF9HWnXeHuoJEt2fH4=
|
||||||
|
github.com/bwmarrin/discordgo v0.23.2/go.mod h1:c1WtWUGN6nREDmzIpyTp/iD3VYt4Fpx+bVyfBG7JE+M=
|
||||||
|
github.com/bwmarrin/discordgo v0.27.1 h1:ib9AIc/dom1E/fSIulrBwnez0CToJE113ZGt4HoliGY=
|
||||||
|
github.com/bwmarrin/discordgo v0.27.1/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
|
||||||
|
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
||||||
|
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
|
github.com/charmbracelet/lipgloss v0.7.1 h1:17WMwi7N1b1rVWOjMT+rCh7sQkvDU75B2hbZpc5Kc1E=
|
||||||
|
github.com/charmbracelet/lipgloss v0.7.1/go.mod h1:yG0k3giv8Qj8edTCbbg6AlQ5e8KNWpFujkNawKNhE2c=
|
||||||
|
github.com/charmbracelet/log v0.2.3 h1:YVmBhJtpGL7nW/nlf5u+SEloU8XYljxozGzZpgwIvhs=
|
||||||
|
github.com/charmbracelet/log v0.2.3/go.mod h1:ZApwwzDbbETVTIRTk7724yQRJAXIktt98yGVMMaa3y8=
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||||
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||||
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
|
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||||
|
github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4=
|
||||||
|
github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
|
||||||
|
github.com/go-redis/redis/v8 v8.10.0/go.mod h1:vXLTvigok0VtUX0znvbcEW1SOt4OA9CU1ZfnOtKOaiM=
|
||||||
|
github.com/go-redis/redis/v8 v8.11.0 h1:O1Td0mQ8UFChQ3N9zFQqo6kTU2cJ+/it88gDB+zg0wo=
|
||||||
|
github.com/go-redis/redis/v8 v8.11.0/go.mod h1:DLomh7y2e3ggQXQLd1YgmvIfecPJoFl7WU5SOQ/r06M=
|
||||||
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||||
|
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||||
|
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
|
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
|
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
|
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||||
|
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||||
|
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||||
|
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
|
github.com/jackmerrill/hamp-api v0.0.0-20230818235104-8d222c9674c9 h1:ZP4cMycNDHXMk5LQ+VbDq7So0e7gbYPetPpvqbD2XLo=
|
||||||
|
github.com/jackmerrill/hamp-api v0.0.0-20230818235104-8d222c9674c9/go.mod h1:KS8EBP1su7OHA4Kq5+wZkx162SEVDbIbUV9yo0MMRac=
|
||||||
|
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||||
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
|
github.com/labstack/echo/v4 v4.9.1 h1:GliPYSpzGKlyOhqIbG8nmHBo3i1saKWFOgh41AN3b+Y=
|
||||||
|
github.com/labstack/echo/v4 v4.9.1/go.mod h1:Pop5HLc+xoc4qhTZ1ip6C0RtP7Z+4VzRLWZZFKqbbjo=
|
||||||
|
github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8=
|
||||||
|
github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM=
|
||||||
|
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||||
|
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||||
|
github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs=
|
||||||
|
github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||||
|
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||||
|
github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98=
|
||||||
|
github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
|
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
||||||
|
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
|
||||||
|
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||||
|
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
|
||||||
|
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
|
||||||
|
github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo=
|
||||||
|
github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8=
|
||||||
|
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||||
|
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
|
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||||
|
github.com/onsi/ginkgo v1.15.0/go.mod h1:hF8qUzuuC8DJGygJH3726JnCZX4MYbRB8yFfISqnKUg=
|
||||||
|
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||||
|
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||||
|
github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
|
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
||||||
|
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
|
github.com/sarulabs/di/v2 v2.4.2 h1:A/PDVU41gHYeUbZZKco8dOwPAB2rrFfiwWLJrZsi+h8=
|
||||||
|
github.com/sarulabs/di/v2 v2.4.2/go.mod h1:trZu4KPwNLE623mBIIsljn1LLkNE6ee/Pk24b7yzSf8=
|
||||||
|
github.com/sashabaranov/go-openai v1.14.2 h1:5DPTtR9JBjKPJS008/A409I5ntFhUPPGCmaAihcPRyo=
|
||||||
|
github.com/sashabaranov/go-openai v1.14.2/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||||
|
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||||
|
github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4=
|
||||||
|
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||||
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
|
github.com/zekroTJA/shireikan v0.7.0 h1:tjsitvaj81Ioeq/EcSIp1aIHkrIH7K5f0Ml4tD8jdIM=
|
||||||
|
github.com/zekroTJA/shireikan v0.7.0/go.mod h1:W9mFLVTrq+mdfLCRqsg9qg8Dd569FxhAeHva4tEzl5s=
|
||||||
|
github.com/zekroTJA/timedmap v1.4.0/go.mod h1:Go4uPxMN1Wjl5IgO6HYD1tM9IQhkYEVqcrrdsI4ljXo=
|
||||||
|
github.com/zekrotja/dgrs v0.3.1 h1:HYKa1wX3WIjUVAj4RhGKhVRvBRhCyofGpHeKyY5W/eg=
|
||||||
|
github.com/zekrotja/dgrs v0.3.1/go.mod h1:I73ryIMJJXCQxBHyBdRALG+0+mIEXF008EF7A/fYV4I=
|
||||||
|
go.opentelemetry.io/otel v0.20.0/go.mod h1:Y3ugLH2oa81t5QO+Lty+zXf8zC9L26ax4Nzoxm/dooo=
|
||||||
|
go.opentelemetry.io/otel v1.0.0-RC1/go.mod h1:x9tRa9HK4hSSq7jf2TKbqFbtt58/TGk0f9XiEYISI1I=
|
||||||
|
go.opentelemetry.io/otel/internal/metric v0.22.0/go.mod h1:7qVuMihW/ktMonEfOvBXuh6tfMvvEyoIDgeJNRloYbQ=
|
||||||
|
go.opentelemetry.io/otel/metric v0.20.0/go.mod h1:598I5tYlH1vzBjn+BTuhzTCSb/9debfNp6R3s7Pr1eU=
|
||||||
|
go.opentelemetry.io/otel/metric v0.22.0/go.mod h1:KcsUkBiYGW003DJ+ugd2aqIRIfjabD9jeOUXqsAtrq0=
|
||||||
|
go.opentelemetry.io/otel/oteltest v0.20.0/go.mod h1:L7bgKf9ZB7qCwT9Up7i9/pn0PWIa9FqQ2IQ8LoxiGnw=
|
||||||
|
go.opentelemetry.io/otel/oteltest v1.0.0-RC1/go.mod h1:+eoIG0gdEOaPNftuy1YScLr1Gb4mL/9lpDkZ0JjMRq4=
|
||||||
|
go.opentelemetry.io/otel/trace v0.20.0/go.mod h1:6GjCW8zgDjwGHGa6GkyeB8+/5vjT16gUEi0Nf1iBdgw=
|
||||||
|
go.opentelemetry.io/otel/trace v1.0.0-RC1/go.mod h1:86UHmyHWFEtWjfWPSbu0+d0Pf9Q6e1U+3ViBOc+NXAg=
|
||||||
|
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||||
|
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
|
||||||
|
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
|
||||||
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
|
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
|
||||||
|
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
|
||||||
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||||
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
|
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
|
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
|
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
|
||||||
|
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
|
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
|
||||||
|
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||||
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
|
||||||
|
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
|
||||||
|
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
|
||||||
|
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
|
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
|
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
|
||||||
|
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
|
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
|
||||||
|
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||||
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||||
|
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||||
|
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||||
|
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||||
|
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||||
|
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||||
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||||
|
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
100
internal/commands/fun/ai.go
Normal file
100
internal/commands/fun/ai.go
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
package fun
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/jackmerrill/hampbot/internal/utils/config"
|
||||||
|
"github.com/jackmerrill/hampbot/internal/utils/embed"
|
||||||
|
"github.com/sashabaranov/go-openai"
|
||||||
|
"github.com/zekroTJA/shireikan"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AI struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AI) GetInvokes() []string {
|
||||||
|
return []string{"ai", "gpt", "ask", "question"}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AI) GetDescription() string {
|
||||||
|
return "Ask AI anything!"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AI) GetHelp() string {
|
||||||
|
return "`ai [prompt]` - Ask GPT-3.5 anything."
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AI) GetGroup() string {
|
||||||
|
return config.GroupFun
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AI) GetDomainName() string {
|
||||||
|
return "hamp.fun.AI"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AI) GetSubPermissionRules() []shireikan.SubPermission {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (c *AI) IsExecutableInDMChannels() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AI) Exec(ctx shireikan.Context) error {
|
||||||
|
openaiToken := os.Getenv("OPENAI_TOKEN")
|
||||||
|
|
||||||
|
if openaiToken == "" {
|
||||||
|
ctx.ReplyEmbed(embed.NewErrorEmbed(ctx).SetDescription("No OpenAI token set.").MessageEmbed)
|
||||||
|
return fmt.Errorf("no openai token set")
|
||||||
|
}
|
||||||
|
|
||||||
|
client := openai.NewClient(openaiToken)
|
||||||
|
|
||||||
|
messages := []openai.ChatCompletionMessage{
|
||||||
|
{
|
||||||
|
Role: openai.ChatMessageRoleSystem,
|
||||||
|
Content: "You are HampBot. You are a bot on Discord that can answer any question. Multiple users may ask you questions at the same time. There will be context given. Don't add any decorations (such as `AI:` or `User:`) to your response, these will be added automatically.",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if ctx.GetChannel().IsThread() {
|
||||||
|
// get all messages in thread
|
||||||
|
msgs, err := ctx.GetSession().ChannelMessages(ctx.GetChannel().ID, 100, "", "", "")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, msg := range msgs {
|
||||||
|
messages = append(messages, openai.ChatCompletionMessage{
|
||||||
|
Role: openai.ChatMessageRoleUser,
|
||||||
|
Content: fmt.Sprintf("%s: %s", msg.Author.Username, msg.Content),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
msg := ctx.GetMessage()
|
||||||
|
|
||||||
|
messages = append(messages, openai.ChatCompletionMessage{
|
||||||
|
Role: openai.ChatMessageRoleUser,
|
||||||
|
Content: fmt.Sprintf("%s: %s", msg.Author.Username, msg.Content),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.GetSession().ChannelTyping(ctx.GetChannel().ID)
|
||||||
|
|
||||||
|
// get response from GPT-3.5
|
||||||
|
resp, err := client.CreateChatCompletion(context.Background(), openai.ChatCompletionRequest{
|
||||||
|
Model: openai.GPT3Dot5Turbo,
|
||||||
|
Messages: messages,
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
ctx.ReplyEmbed(embed.NewErrorEmbed(ctx).SetDescription("An error occured while asking GPT-3.5.").AddField("Error", err.Error(), false).MessageEmbed)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// send response
|
||||||
|
ctx.GetSession().ChannelMessageSend(ctx.GetChannel().ID, fmt.Sprintf(":robot: **AI:** %s", resp.Choices[0].Message.Content))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
122
internal/commands/studentlife/laundry.go
Normal file
122
internal/commands/studentlife/laundry.go
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
package studentlife
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/bwmarrin/discordgo"
|
||||||
|
"github.com/jackmerrill/hampbot/internal/utils/config"
|
||||||
|
"github.com/jackmerrill/hampbot/internal/utils/embed"
|
||||||
|
"github.com/zekroTJA/shireikan"
|
||||||
|
)
|
||||||
|
|
||||||
|
type MachineType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
Washer MachineType = "Washer"
|
||||||
|
Dryer MachineType = "Dryer"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Machine struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type MachineType `json:"type"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
Time *time.Time `json:"time"`
|
||||||
|
EstimatedTime *time.Time `json:"estimatedTime"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LaundryRoom struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
NextUpdate time.Time `json:"nextUpdate"`
|
||||||
|
LastUpdate time.Time `json:"lastUpdate"`
|
||||||
|
|
||||||
|
Machines []Machine `json:"machines"`
|
||||||
|
|
||||||
|
updateChan chan bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type Laundry struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Laundry) GetInvokes() []string {
|
||||||
|
return []string{"laundry"}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Laundry) GetDescription() string {
|
||||||
|
return "Get the laundry status of a residence hall"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Laundry) GetHelp() string {
|
||||||
|
return "`laundry [dakin/merrill/prescott/enfield]` - Laundry help"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Laundry) GetGroup() string {
|
||||||
|
return config.GroupUtil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Laundry) GetDomainName() string {
|
||||||
|
return "hamp.util.laundry"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Laundry) GetSubPermissionRules() []shireikan.SubPermission {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (c *Laundry) IsExecutableInDMChannels() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Laundry) Exec(ctx shireikan.Context) error {
|
||||||
|
building := ctx.GetArgs().Get(0)
|
||||||
|
|
||||||
|
if building == "" {
|
||||||
|
ctx.GetSession().ChannelMessageSendComplex(ctx.GetChannel().ID, &discordgo.MessageSend{
|
||||||
|
Embed: embed.NewErrorEmbed(ctx).SetDescription("Please specify a building to get the laundry status of.\n\n**Usage:** `laundry [dakin/merrill/prescott/enfield]`").MessageEmbed,
|
||||||
|
Reference: ctx.GetMessage().Reference(),
|
||||||
|
})
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if building != "dakin" && building != "merrill" && building != "prescott" && building != "enfield" {
|
||||||
|
ctx.GetSession().ChannelMessageSendComplex(ctx.GetChannel().ID, &discordgo.MessageSend{
|
||||||
|
Embed: embed.NewErrorEmbed(ctx).SetDescription("Please specify a valid building to get the laundry status of.\n\n**Usage:** `laundry [dakin/merrill/prescott/enfield]`").MessageEmbed,
|
||||||
|
Reference: ctx.GetMessage().Reference(),
|
||||||
|
})
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := http.Get(fmt.Sprintf("%s/api/utilities/laundry/%s", config.HampAPI, ctx.GetArgs().Get(0)))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var room LaundryRoom
|
||||||
|
|
||||||
|
err = json.NewDecoder(res.Body).Decode(&room)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
embed := embed.NewSuccessEmbed(ctx).SetTitle(fmt.Sprintf("%s Laundry Status :shirt:", room.Name)).SetDescription(fmt.Sprintf("Last update: %s", config.ConvertTimestampToDiscordTimestampWithFormat(room.LastUpdate, "T")))
|
||||||
|
|
||||||
|
for _, machine := range room.Machines {
|
||||||
|
if machine.Status == "Available" {
|
||||||
|
embed.AddField(fmt.Sprintf("%s - %s", machine.Name, machine.Type), fmt.Sprintf(":green_circle: **Status:** %s", machine.Status), false)
|
||||||
|
} else if machine.Status == "Not online" {
|
||||||
|
embed.AddField(fmt.Sprintf("%s - %s", machine.Name, machine.Type), fmt.Sprintf(":red_circle: **Status:** %s", machine.Status), false)
|
||||||
|
} else {
|
||||||
|
embed.AddField(fmt.Sprintf("%s - %s", machine.Name, machine.Type), fmt.Sprintf(":yellow_circle: **Status:** %s\n:alarm_clock: **Time Remaining:** %s", machine.Status, config.ConvertTimestampToDiscordTimestampWithFormat(*machine.EstimatedTime, "R")), false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.GetSession().ChannelMessageSendComplex(ctx.GetChannel().ID, &discordgo.MessageSend{
|
||||||
|
Embed: embed.MessageEmbed,
|
||||||
|
Reference: ctx.GetMessage().Reference(),
|
||||||
|
})
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
79
internal/commands/util/ping.go
Normal file
79
internal/commands/util/ping.go
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
package commands
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/bwmarrin/discordgo"
|
||||||
|
"github.com/charmbracelet/log"
|
||||||
|
"github.com/jackmerrill/hampbot/internal/utils/config"
|
||||||
|
"github.com/jackmerrill/hampbot/internal/utils/embed"
|
||||||
|
"github.com/zekroTJA/shireikan"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Ping is a command responding with a ping
|
||||||
|
// message in the commands channel.
|
||||||
|
type Ping struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetInvoke returns the command invokes.
|
||||||
|
func (c *Ping) GetInvokes() []string {
|
||||||
|
return []string{"ping", "p"}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetDescription returns the commands description.
|
||||||
|
func (c *Ping) GetDescription() string {
|
||||||
|
return "ping pong"
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetHelp returns the commands help text.
|
||||||
|
func (c *Ping) GetHelp() string {
|
||||||
|
return "`ping` - ping"
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetGroup returns the commands group.
|
||||||
|
func (c *Ping) GetGroup() string {
|
||||||
|
return config.GroupUtil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetDomainName returns the commands domain name.
|
||||||
|
func (c *Ping) GetDomainName() string {
|
||||||
|
return "hamp.util.ping"
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSubPermissionRules returns the commands sub
|
||||||
|
// permissions array.
|
||||||
|
func (c *Ping) GetSubPermissionRules() []shireikan.SubPermission {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsExecutableInDMChannels returns whether
|
||||||
|
// the command is executable in DM channels.
|
||||||
|
func (c *Ping) IsExecutableInDMChannels() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec is the commands execution handler.
|
||||||
|
func (c *Ping) Exec(ctx shireikan.Context) error {
|
||||||
|
start := time.Now()
|
||||||
|
|
||||||
|
m, err := ctx.GetSession().ChannelMessageSendComplex(ctx.GetChannel().ID, &discordgo.MessageSend{
|
||||||
|
Reference: ctx.GetMessage().Reference(),
|
||||||
|
Embed: embed.NewWarningEmbed(ctx).SetTitle("Pinging... <a:whencat:993983100805730415>").MessageEmbed,
|
||||||
|
})
|
||||||
|
|
||||||
|
end := time.Now()
|
||||||
|
diff := end.Sub(start)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Failed sending message: ", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = ctx.GetSession().ChannelMessageEditComplex(&discordgo.MessageEdit{
|
||||||
|
Channel: ctx.GetChannel().ID,
|
||||||
|
ID: m.ID,
|
||||||
|
Embed: embed.NewSuccessEmbed(ctx).SetTitle("Pong! :ping_pong:").SetDescription(fmt.Sprintf(":ping_pong: Gateway Ping: `%dms`\n:desktop: API Ping: `%dms`", ctx.GetSession().HeartbeatLatency().Milliseconds(), diff.Milliseconds())).MessageEmbed,
|
||||||
|
})
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
98
internal/commands/util/steal.go
Normal file
98
internal/commands/util/steal.go
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
package commands
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/bwmarrin/discordgo"
|
||||||
|
"github.com/jackmerrill/hampbot/internal/utils/config"
|
||||||
|
"github.com/jackmerrill/hampbot/internal/utils/embed"
|
||||||
|
"github.com/zekroTJA/shireikan"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Steal struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Steal) GetInvokes() []string {
|
||||||
|
return []string{"steal", "emote"}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Steal) GetDescription() string {
|
||||||
|
return "Steal an emote from another server"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Steal) GetHelp() string {
|
||||||
|
return "`steal [emote(s)]` - steal an emote from another server\n`steal [emote(s)]` - steal an emote (or two) from another server"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Steal) GetGroup() string {
|
||||||
|
return config.GroupUtil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Steal) GetDomainName() string {
|
||||||
|
return "hamp.util.steal"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Steal) GetSubPermissionRules() []shireikan.SubPermission {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (c *Steal) IsExecutableInDMChannels() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Steal) Exec(ctx shireikan.Context) error {
|
||||||
|
msg := ctx.GetMessage()
|
||||||
|
|
||||||
|
emotes := msg.GetCustomEmojis()
|
||||||
|
|
||||||
|
if len(emotes) == 0 {
|
||||||
|
ctx.GetSession().ChannelMessageSendEmbed(msg.ChannelID, embed.NewErrorEmbed(ctx).SetTitle("No emotes found").SetDescription("No emotes were found in your message.").MessageEmbed)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var newEmojis []string
|
||||||
|
|
||||||
|
for _, emote := range emotes {
|
||||||
|
// download the emote
|
||||||
|
res, err := http.Get(fmt.Sprintf("https://cdn.discordapp.com/emojis/%s", emote.ID))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
ctx.GetSession().ChannelMessageSendEmbed(msg.ChannelID, embed.NewErrorEmbed(ctx).SetTitle("Error").SetDescription("An error occured while downloading your emote.").AddField("Error", err.Error(), false).MessageEmbed)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer res.Body.Close()
|
||||||
|
|
||||||
|
data, err := ioutil.ReadAll(res.Body)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
ctx.GetSession().ChannelMessageSendEmbed(msg.ChannelID, embed.NewErrorEmbed(ctx).SetTitle("Error").SetDescription("An error occured while downloading your emote.").AddField("Error", err.Error(), false).MessageEmbed)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert to base64
|
||||||
|
base64Emote := base64.StdEncoding.EncodeToString(data)
|
||||||
|
|
||||||
|
emoji := discordgo.EmojiParams{
|
||||||
|
Name: emote.Name,
|
||||||
|
Image: "data:image/png;base64," + base64Emote,
|
||||||
|
Roles: nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = ctx.GetSession().GuildEmojiCreate(config.BotGuild, &emoji)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
ctx.GetSession().ChannelMessageSendEmbed(msg.ChannelID, embed.NewErrorEmbed(ctx).SetTitle("Error").SetDescription("An error occured while uploading your emote.").AddField("Error", err.Error(), false).MessageEmbed)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
newEmojis = append(newEmojis, emote.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.GetSession().ChannelMessageSendEmbed(msg.ChannelID, embed.NewSuccessEmbed(ctx).SetTitle("Emote(s) stolen!").SetDescription(fmt.Sprintf("The following emotes were stolen: `%s`", strings.Join(newEmojis, ", "))).MessageEmbed)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
47
internal/utils/config/config.go
Normal file
47
internal/utils/config/config.go
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
Version string
|
||||||
|
Build string
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// BotPrefix is the prefix used for bot commands.
|
||||||
|
BotPrefix = ">"
|
||||||
|
|
||||||
|
// BotGuild is the ID of the guild the bot is running on.
|
||||||
|
BotGuild = "936651575684915201"
|
||||||
|
|
||||||
|
// HampAPI is the URL to the hamp API.
|
||||||
|
// HampAPI = "https://api.hamp.sh"
|
||||||
|
HampAPI = "http://localhost:1323"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
GroupUtil = "Util"
|
||||||
|
GroupFun = "Fun"
|
||||||
|
GroupInfo = "Info"
|
||||||
|
GroupMod = "Moderation"
|
||||||
|
GroupDev = "Dev"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ConvertTimestampToDiscordTimestamp(t time.Time) string {
|
||||||
|
// format: <t:1234567890> where 1234567890 is the unix timestamp
|
||||||
|
|
||||||
|
u := t.Unix()
|
||||||
|
|
||||||
|
return "<t:" + fmt.Sprint(u) + ">"
|
||||||
|
}
|
||||||
|
|
||||||
|
func ConvertTimestampToDiscordTimestampWithFormat(t time.Time, format string) string {
|
||||||
|
// format: <t:1234567890:R> where 1234567890 is the unix timestamp and R is the format
|
||||||
|
|
||||||
|
u := t.Unix()
|
||||||
|
|
||||||
|
return "<t:" + fmt.Sprint(u) + ":" + format + ">"
|
||||||
|
}
|
103
internal/utils/embed/embed.go
Normal file
103
internal/utils/embed/embed.go
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
package embed
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/bwmarrin/discordgo"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Embed struct {
|
||||||
|
*discordgo.MessageEmbed
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewEmbed() *Embed {
|
||||||
|
return &Embed{&discordgo.MessageEmbed{}}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Embed) SetTitle(title string) *Embed {
|
||||||
|
e.MessageEmbed.Title = title
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Embed) SetDescription(description string) *Embed {
|
||||||
|
e.MessageEmbed.Description = description
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Embed) SetColor(color int) *Embed {
|
||||||
|
e.MessageEmbed.Color = color
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Embed) SetColorRGB(r, g, b int) *Embed {
|
||||||
|
return e.SetColor((r << 16) + (g << 8) + b)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Embed) SetColorHex(hex string) *Embed {
|
||||||
|
var color int
|
||||||
|
fmt.Sscanf(hex, "#%06x", &color)
|
||||||
|
return e.SetColor(color)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Embed) SetURL(url string) *Embed {
|
||||||
|
e.MessageEmbed.URL = url
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Embed) SetTimestamp(timestamp time.Time) *Embed {
|
||||||
|
e.MessageEmbed.Timestamp = timestamp.Format(time.RFC3339)
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Embed) SetFooter(text, iconURL string) *Embed {
|
||||||
|
e.MessageEmbed.Footer = &discordgo.MessageEmbedFooter{
|
||||||
|
Text: text,
|
||||||
|
IconURL: iconURL,
|
||||||
|
}
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Embed) SetImage(url string) *Embed {
|
||||||
|
e.MessageEmbed.Image = &discordgo.MessageEmbedImage{
|
||||||
|
URL: url,
|
||||||
|
}
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Embed) SetThumbnail(url string) *Embed {
|
||||||
|
e.MessageEmbed.Thumbnail = &discordgo.MessageEmbedThumbnail{
|
||||||
|
URL: url,
|
||||||
|
}
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Embed) SetAuthor(name, url, iconURL string) *Embed {
|
||||||
|
e.MessageEmbed.Author = &discordgo.MessageEmbedAuthor{
|
||||||
|
Name: name,
|
||||||
|
URL: url,
|
||||||
|
IconURL: iconURL,
|
||||||
|
}
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Embed) AddField(name, value string, inline bool) *Embed {
|
||||||
|
e.MessageEmbed.Fields = append(e.MessageEmbed.Fields, &discordgo.MessageEmbedField{
|
||||||
|
Name: name,
|
||||||
|
Value: value,
|
||||||
|
Inline: inline,
|
||||||
|
})
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Embed) AddFields(fields ...*discordgo.MessageEmbedField) *Embed {
|
||||||
|
e.MessageEmbed.Fields = append(e.MessageEmbed.Fields, fields...)
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Embed) AddFieldsFromMap(fields map[string]string, inline bool) *Embed {
|
||||||
|
for name, value := range fields {
|
||||||
|
e.AddField(name, value, inline)
|
||||||
|
}
|
||||||
|
return e
|
||||||
|
}
|
24
internal/utils/embed/prebuild_embeds.go
Normal file
24
internal/utils/embed/prebuild_embeds.go
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
package embed
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/jackmerrill/hampbot/internal/utils/config"
|
||||||
|
"github.com/zekroTJA/shireikan"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewGenericEmbed(ctx shireikan.Context) *Embed {
|
||||||
|
return NewEmbed().SetFooter(fmt.Sprintf("HampBot %s", config.Version), ctx.GetSession().State.User.AvatarURL("256"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSuccessEmbed(ctx shireikan.Context) *Embed {
|
||||||
|
return NewGenericEmbed(ctx).SetColor(0x00ff00)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewWarningEmbed(ctx shireikan.Context) *Embed {
|
||||||
|
return NewGenericEmbed(ctx).SetColor(0xffff00)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewErrorEmbed(ctx shireikan.Context) *Embed {
|
||||||
|
return NewGenericEmbed(ctx).SetColor(0xff0000).SetTitle("Error")
|
||||||
|
}
|
67
main.go
Normal file
67
main.go
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
|
"github.com/bwmarrin/discordgo"
|
||||||
|
"github.com/jackmerrill/hampbot/internal/commands/fun"
|
||||||
|
studentlife "github.com/jackmerrill/hampbot/internal/commands/studentlife"
|
||||||
|
util "github.com/jackmerrill/hampbot/internal/commands/util"
|
||||||
|
"github.com/zekroTJA/shireikan"
|
||||||
|
|
||||||
|
"github.com/charmbracelet/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
token := os.Getenv("TOKEN")
|
||||||
|
|
||||||
|
session, err := discordgo.New("Bot " + token)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Info("Starting bot...")
|
||||||
|
|
||||||
|
err = session.Open()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
sc := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
|
||||||
|
<-sc
|
||||||
|
}()
|
||||||
|
|
||||||
|
handler := shireikan.New(&shireikan.Config{
|
||||||
|
GeneralPrefix: ">",
|
||||||
|
AllowBots: false,
|
||||||
|
AllowDM: true,
|
||||||
|
ExecuteOnEdit: true,
|
||||||
|
InvokeToLower: true,
|
||||||
|
UseDefaultHelpCommand: true,
|
||||||
|
OnError: func(ctx shireikan.Context, typ shireikan.ErrorType, err error) {
|
||||||
|
log.Error(err)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
log.Info("Registering commands...")
|
||||||
|
|
||||||
|
handler.Register(&util.Ping{})
|
||||||
|
log.Debug("Registered ping command")
|
||||||
|
|
||||||
|
handler.Register(&studentlife.Laundry{})
|
||||||
|
log.Debug("Registered laundry command")
|
||||||
|
|
||||||
|
handler.Register(&util.Steal{})
|
||||||
|
log.Debug("Registered steal command")
|
||||||
|
|
||||||
|
handler.Register(&fun.AI{})
|
||||||
|
log.Debug("Registered ai command")
|
||||||
|
|
||||||
|
handler.Setup(session)
|
||||||
|
|
||||||
|
log.Info("Bot is now running. Press CTRL-C to exit.")
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user