Compare commits

..
28 Commits
Author SHA1 Message Date
wayfinderak 5197c9abf8 Fix database initialization connection leaks
Build and Push Container / build-and-push (push) Successful in 2m18s
2026-05-07 18:34:18 -08:00
wayfinderak b92a2fff97 Tag latest image from master branch
Build and Push Container / build-and-push (push) Successful in 4m31s
2026-05-07 15:17:33 -08:00
wayfinderak 4aff642c51 Add Portainer deployment files
Build and Push Container / build-and-push (push) Failing after 17m55s
2026-05-07 13:55:20 -08:00
wayfinderak 49fc4f0c6e Update .gitea/workflows/build-and-push.yml
Build and Push Container / build-and-push (push) Successful in 2m25s
2026-03-23 06:07:10 +00:00
wayfinderak 79afca5e98 Update .gitea/workflows/build-and-push.yml
Build and Push Container / build-and-push (push) Has been cancelled
2026-03-23 06:04:51 +00:00
wayfinderak 33330c16e3 Update .gitea/workflows/build-and-push.yml
Build and Push Container / build-and-push (push) Failing after 2m43s
2026-03-23 06:01:16 +00:00
wayfinderak 0f0d91f994 Update .gitea/workflows/build-and-push.yml
Build and Push Container / build-and-push (push) Has been cancelled
2026-03-23 05:41:43 +00:00
wayfinderak cf6b7eae81 Migrate deployment to Gitea Actions and Portainer
Build and Push Container / docker (push) Has been cancelled
2026-03-22 11:43:22 -08:00
Dustin Pianalto aea88c632e Add pgbouncer
CI / build (push) Has been cancelled
2021-10-10 20:26:32 -08:00
Dustin Pianalto dd60c9067b Add pgbouncer
CI / build (push) Has been cancelled
2021-10-10 19:56:13 -08:00
Dustin Pianalto 03818d6102 Add pgbouncer
CI / build (push) Has been cancelled
2021-10-10 19:31:01 -08:00
Dustin Pianalto 4e1ca8a700 Add pgbouncer
CI / build (push) Has been cancelled
2021-10-10 19:23:52 -08:00
Dustin Pianalto be0ed2a40d Add pgbouncer
CI / build (push) Has been cancelled
2021-10-10 18:37:26 -08:00
Dustin Pianalto af07976c78 Add pgbouncer
CI / build (push) Has been cancelled
2021-10-10 18:18:40 -08:00
Dusty.P fb4f43c234 Update deployment.yml
CI / build (push) Has been cancelled
2021-10-05 23:45:08 -08:00
Dustin Pianalto 34a6c0cdd3 Merge branch 'master' of github.com:dustinpianalto/Goff
CI / build (push) Has been cancelled
2021-10-05 23:34:30 -08:00
Dusty.P a6cde5c69c Update main.yml
CI / build (push) Has been cancelled
2021-10-05 23:09:00 -08:00
Dustin Pianalto a2420f19c9 Update deployment
CI / build (push) Has been cancelled
2021-10-02 16:18:48 -08:00
Dustin Pianalto 2019dc4643 Update GH action and deployment
CI / build (push) Has been cancelled
2021-10-02 14:13:28 -08:00
Dustin Pianalto 9bb35bb30a Don't check roles when adding
CI / build (push) Has been cancelled
2021-08-18 14:24:20 -08:00
Dustin Pianalto 3cad5680b0 Add guild member update handler
CI / build (push) Has been cancelled
2021-08-18 11:26:25 -08:00
Dustin Pianalto f97494626f Don't add auto role until after membership check
CI / build (push) Has been cancelled
2021-08-18 11:01:24 -08:00
Dustin Pianalto b5a55a1b77 Don't add auto role until after membership check 2021-08-18 11:00:31 -08:00
Dustin Pianalto 02b5842107 Add milliseconds to timestamp
CI / build (push) Has been cancelled
2021-07-23 12:54:23 -08:00
Dustin Pianalto d345044b3a Add milliseconds to timestamp
CI / build (push) Has been cancelled
2021-07-23 12:39:35 -08:00
Dustin Pianalto b3aff0828c Add snowflake command
CI / build (push) Has been cancelled
2021-07-23 12:34:09 -08:00
Dustin Pianalto 3d4518f961 Don't log message edits if the After is blank (problem with message embeds)
CI / build (push) Has been cancelled
2021-07-01 19:54:12 -08:00
Dustin Pianalto 37e8fa52af Fix bug in getting tasks
CI / build (push) Has been cancelled
2021-06-22 12:58:42 -08:00
35 changed files with 489 additions and 134 deletions
+6
View File
@@ -0,0 +1,6 @@
.git
.github
.gitea
.env
.idea
goff
+135
View File
@@ -0,0 +1,135 @@
name: Build and Push Container
on:
push:
branches:
- master
- main
tags:
- v*
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
env:
REGISTRY: gitea.wayfinderak.com
IMAGE_NAME: gitea.wayfinderak.com/wayfinderak/goff
container:
options: --dns 172.16.30.10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Go and Docker CLI if needed
shell: bash
run: |
set -euo pipefail
need_apt=0
need_apk=0
if ! command -v go >/dev/null 2>&1 || ! command -v docker >/dev/null 2>&1; then
if command -v apt-get >/dev/null 2>&1; then
need_apt=1
elif command -v apk >/dev/null 2>&1; then
need_apk=1
else
echo "No supported package manager found" >&2
exit 1
fi
fi
if [ "$need_apt" -eq 1 ]; then
apt-get update
if ! command -v go >/dev/null 2>&1; then
apt-get install -y golang-go
fi
if ! command -v docker >/dev/null 2>&1; then
apt-get install -y docker.io curl dnsutils iputils-ping
fi
fi
if [ "$need_apk" -eq 1 ]; then
if ! command -v go >/dev/null 2>&1; then
apk add --no-cache go
fi
if ! command -v docker >/dev/null 2>&1; then
apk add --no-cache docker-cli curl bind-tools iputils
fi
fi
go version
docker version
- name: Run tests
run: go test ./...
- name: Log in to Gitea Container Registry
shell: bash
run: |
set -euo pipefail
for attempt in 1 2 3; do
echo "docker login attempt $attempt"
if echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login "$REGISTRY" -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin; then
exit 0
fi
sleep 5
done
echo "docker login failed after 3 attempts" >&2
exit 1
- name: Determine image tags
id: meta
shell: bash
env:
REF: ${{ gitea.ref }}
REF_NAME: ${{ gitea.ref_name }}
SHA: ${{ gitea.sha }}
run: |
set -euo pipefail
tags=()
if [[ "$REF" == refs/tags/* ]]; then
version="$REF_NAME"
tags+=("$IMAGE_NAME:$version")
tags+=("$IMAGE_NAME:latest")
else
branch="$REF_NAME"
branch_safe="$(echo "$branch" | tr '/_' '--')"
sha_short="$(echo "$SHA" | cut -c1-7)"
tags+=("$IMAGE_NAME:$branch_safe")
tags+=("$IMAGE_NAME:$branch_safe-$sha_short")
if [[ "$branch" == "main" || "$branch" == "master" ]]; then
tags+=("$IMAGE_NAME:latest")
fi
fi
printf 'tags<<EOF\n' >> "$GITHUB_OUTPUT"
printf '%s\n' "${tags[@]}" >> "$GITHUB_OUTPUT"
printf 'EOF\n' >> "$GITHUB_OUTPUT"
- name: Build image
shell: bash
run: |
set -euo pipefail
mapfile -t tags <<'EOF'
${{ steps.meta.outputs.tags }}
EOF
build_args=()
for tag in "${tags[@]}"; do
build_args+=(--tag "$tag")
done
docker build "${build_args[@]}" .
- name: Push image
shell: bash
run: |
set -euo pipefail
while IFS= read -r tag; do
[ -n "$tag" ] || continue
docker push "$tag"
done <<'EOF'
${{ steps.meta.outputs.tags }}
EOF
+47 -35
View File
@@ -1,52 +1,64 @@
name: CI name: Build and Push Container
# Controls when the action will run. Triggers the workflow on push to master or development
# with a tag like v1.0.0 or v1.0.0-dev
on: on:
push: push:
branches:
- master
- main
tags: tags:
- v[0-9]+.[0-9]+.[0-9]+ - v*
- v[0-9]+.[0-9]+.[0-9]+-[a-zA-Z]+ workflow_dispatch:
env:
REGISTRY: gitea.wayfinderak.com
IMAGE_NAME: wayfinderak/goff
jobs: jobs:
build: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps: steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Checkout
- uses: actions/checkout@v2 uses: actions/checkout@v4
- name: Get Version - name: Set up QEMU
id: get_version uses: docker/setup-qemu-action@v3
uses: battila7/get-version-action@v2.0.0
- name: Build container image - name: Set up Docker Buildx
env: uses: docker/setup-buildx-action@v3
IMAGE_TAG: ${{ steps.get_version.outputs.version-without-v }}
run: docker build -t registry.digitalocean.com/djpianalto/goff:$IMAGE_TAG .
- name: Install doctl - name: Log in to Gitea registry
uses: digitalocean/action-doctl@v2 uses: docker/login-action@v3
with: with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Login to DigitalOcean Container Registry with short-lived credentials - name: Prepare image tags
run: doctl registry login --expiry-seconds 600 id: prep
shell: bash
run: |
short_sha="${GITHUB_SHA::7}"
tags="${REGISTRY}/${IMAGE_NAME}:sha-${short_sha}"
- name: Push image to DigitalOcean Container Registry if [[ "${GITHUB_REF_TYPE}" == "branch" && ("${GITHUB_REF_NAME}" == "master" || "${GITHUB_REF_NAME}" == "main") ]]; then
env: tags+=$'\n'"${REGISTRY}/${IMAGE_NAME}:latest"
IMAGE_TAG: ${{ steps.get_version.outputs.version-without-v }} fi
run: docker push registry.digitalocean.com/djpianalto/goff:$IMAGE_TAG
- name: Update deployment file if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
run: TAG=${{ steps.get_version.outputs.version-without-v }} && sed -i 's|<IMAGE>|registry.digitalocean.com/djpianalto/goff:'${TAG}'|' $GITHUB_WORKSPACE/deployment.yml version="${GITHUB_REF_NAME#v}"
tags+=$'\n'"${REGISTRY}/${IMAGE_NAME}:${version}"
fi
- name: Save DigitalOcean kubeconfig with short-lived credentials {
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 discord-bots echo 'tags<<EOF'
echo "$tags"
echo 'EOF'
} >> "$GITHUB_OUTPUT"
- name: Deploy to DigitalOcean Kubernetes - name: Build and push image
run: kubectl apply -f $GITHUB_WORKSPACE/deployment.yml uses: docker/build-push-action@v6
with:
- name: Verify deployment context: .
run: kubectl rollout status deployment/goff push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.prep.outputs.tags }}
+10 -12
View File
@@ -1,20 +1,18 @@
FROM golang:1.14-alpine as dev FROM golang:1.22-alpine AS builder
WORKDIR /go/src/Goff WORKDIR /src
COPY ./go.mod . RUN apk add --no-cache ca-certificates git tzdata
COPY ./go.sum .
COPY go.mod go.sum ./
RUN go mod download RUN go mod download
COPY . . COPY . .
RUN go install github.com/dustinpianalto/goff/... ARG TARGETARCH=amd64
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go build -o /out/goff ./cmd/goff
CMD [ "go", "run", "cmd/goff/main.go"] FROM alpine:3.20
RUN apk add --no-cache ca-certificates tzdata
from alpine COPY --from=builder /out/goff /usr/local/bin/goff
WORKDIR /bin ENTRYPOINT ["/usr/local/bin/goff"]
COPY --from=dev /go/bin/goff ./goff
CMD [ "goff" ]
+26
View File
@@ -0,0 +1,26 @@
# Portainer deployment notes
Generated from the current Kubernetes deployment in namespace `discord-bots`. Secret values are in the local `portainer-*.env` files.
## Kubernetes source
- Deployment: `goff`
- Replicas: `1`
- Rolling update: maxSurge `1`, maxUnavailable `1`
- minReadySeconds: `120`
- Labels/selectors: `app=goff`
- Image pull secrets: `none required for Portainer stack`
## Containers
- `pgbouncer`: image `timoha/pgbouncer:1.15.0`; env: DATABASE_URL, SERVER_TLS_SSLMODE, AUTH_TYPE; ports: 5432; requests: {'cpu': '500m', 'memory': '256Mi'}; limits: {'cpu': '1', 'memory': '512Mi'}
- `goff`: image `gitea.wayfinderak.com/wayfinderak/goff:latest`; env: DATABASE_URL, DISCORDGO_TOKEN, GOFF_EMAIL_USERNAME, GOFF_EMAIL_PASSWORD; ports: none; requests: {'cpu': '1', 'memory': '512Mi'}; limits: {'cpu': '2', 'memory': '1Gi'}
## Portainer files
- `portainer-stack.yml` - Docker Compose stack to paste/use in Portainer.
- `portainer-app.env` - bot runtime secrets/env.
## Portainer database connection
This Portainer stack does not include pgbouncer. `DATABASE_URL` in `portainer-app.env` points directly at the external PostgreSQL service copied from the Kubernetes pgbouncer upstream URL.
Executable → Regular
View File
+10 -8
View File
@@ -4,15 +4,15 @@ import (
"fmt" "fmt"
"log" "log"
"gitea.wayfinderak.com/wayfinderak/goff/internal/exts"
"gitea.wayfinderak.com/wayfinderak/goff/internal/exts/guild_management"
"gitea.wayfinderak.com/wayfinderak/goff/internal/exts/logging"
"gitea.wayfinderak.com/wayfinderak/goff/internal/exts/tasks"
"gitea.wayfinderak.com/wayfinderak/goff/internal/exts/user_management"
"gitea.wayfinderak.com/wayfinderak/goff/internal/postgres"
"gitea.wayfinderak.com/wayfinderak/goff/internal/services"
"gitea.wayfinderak.com/wayfinderak/goff/pkg/email"
"github.com/dustinpianalto/disgoman" "github.com/dustinpianalto/disgoman"
"github.com/dustinpianalto/goff/internal/exts"
"github.com/dustinpianalto/goff/internal/exts/guild_management"
"github.com/dustinpianalto/goff/internal/exts/logging"
"github.com/dustinpianalto/goff/internal/exts/tasks"
"github.com/dustinpianalto/goff/internal/exts/user_management"
"github.com/dustinpianalto/goff/internal/postgres"
"github.com/dustinpianalto/goff/internal/services"
"github.com/dustinpianalto/goff/pkg/email"
//"github.com/MikeModder/anpan" //"github.com/MikeModder/anpan"
"os" "os"
@@ -86,6 +86,7 @@ func main() {
dg.AddHandler(user_management.OnGuildMemberAdd) dg.AddHandler(user_management.OnGuildMemberAdd)
dg.AddHandler(user_management.OnGuildMemberRemoveLogging) dg.AddHandler(user_management.OnGuildMemberRemoveLogging)
dg.AddHandler(user_management.OnGuildMemberRemove) dg.AddHandler(user_management.OnGuildMemberRemove)
dg.AddHandler(user_management.OnGuildMemberUpdate)
err = dg.Open() err = dg.Open()
if err != nil { if err != nil {
@@ -123,6 +124,7 @@ func getPrefixes(guildID string) []string {
log.Println(err) log.Println(err)
return []string{"Go.", "go."} return []string{"Go.", "go."}
} }
defer rows.Close()
var prefixes []string var prefixes []string
for rows.Next() { for rows.Next() {
var prefix string var prefix string
+37 -1
View File
@@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: goff name: goff
namespace: default namespace: discord-bots
labels: labels:
app: goff app: goff
spec: spec:
@@ -21,8 +21,42 @@ spec:
app: goff app: goff
spec: spec:
containers: containers:
- name: pgbouncer
image: timoha/pgbouncer:1.15.0
resources:
requests:
memory: "256Mi"
cpu: "0.5"
limits:
memory: "512Mi"
cpu: "1"
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: goff
key: pgbouncer_url
- name: SERVER_TLS_SSLMODE
valueFrom:
secretKeyRef:
name: goff
key: pgbouncer_ssl
- name: AUTH_TYPE
valueFrom:
secretKeyRef:
name: goff
key: pgbouncer_auth
ports:
- containerPort: 5432
- name: goff - name: goff
image: <IMAGE> image: <IMAGE>
resources:
requests:
memory: "512Mi"
cpu: "1"
limits:
memory: "1Gi"
cpu: "2"
env: env:
- name: DATABASE_URL - name: DATABASE_URL
valueFrom: valueFrom:
@@ -44,3 +78,5 @@ spec:
secretKeyRef: secretKeyRef:
name: goff name: goff
key: email_password key: email_password
imagePullSecrets:
- name: registry-1
+10
View File
@@ -0,0 +1,10 @@
services:
goff:
image: ${IMAGE:-gitea.wayfinderak.com/wayfinderak/goff:${IMAGE_TAG:-latest}}
container_name: goff
restart: unless-stopped
environment:
DATABASE_URL: ${DATABASE_URL}
DISCORDGO_TOKEN: ${DISCORDGO_TOKEN}
GOFF_EMAIL_USERNAME: ${GOFF_EMAIL_USERNAME}
GOFF_EMAIL_PASSWORD: ${GOFF_EMAIL_PASSWORD}
+12 -6
View File
@@ -1,14 +1,20 @@
module github.com/dustinpianalto/goff module gitea.wayfinderak.com/wayfinderak/goff
go 1.14 go 1.14
require ( require (
github.com/bwmarrin/discordgo v0.22.0 github.com/AlekSi/pointer v1.1.0 // indirect
github.com/dustinpianalto/disgoman v0.0.15 github.com/bwmarrin/discordgo v0.23.2
github.com/dustinpianalto/disgoman v0.0.21
github.com/dustinpianalto/rpnparse v1.0.1 github.com/dustinpianalto/rpnparse v1.0.1
github.com/emersion/go-imap v1.0.5 github.com/emersion/go-imap v1.1.0
github.com/emersion/go-message v0.12.0 github.com/emersion/go-message v0.15.0
github.com/gorilla/websocket v1.4.2 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/lib/pq v1.3.0 github.com/lib/pq v1.10.2
github.com/olebedev/when v0.0.0-20190311101825-c3b538a97254 github.com/olebedev/when v0.0.0-20190311101825-c3b538a97254
github.com/pkg/errors v0.9.1 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/sys v0.0.0-20210818153620-00dd8d7831e7 // indirect
golang.org/x/text v0.3.7 // indirect
) )
+37
View File
@@ -1,11 +1,15 @@
github.com/AlekSi/pointer v1.0.0 h1:KWCWzsvFxNLcmM5XmiqHsGTTsuwZMsLFwWF9Y+//bNE= github.com/AlekSi/pointer v1.0.0 h1:KWCWzsvFxNLcmM5XmiqHsGTTsuwZMsLFwWF9Y+//bNE=
github.com/AlekSi/pointer v1.0.0/go.mod h1:1kjywbfcPFCmncIxtk6fIEub6LKrfMz3gc5QKVOSOA8= github.com/AlekSi/pointer v1.0.0/go.mod h1:1kjywbfcPFCmncIxtk6fIEub6LKrfMz3gc5QKVOSOA8=
github.com/AlekSi/pointer v1.1.0 h1:SSDMPcXD9jSl8FPy9cRzoRaMJtm9g9ggGTxecRUbQoI=
github.com/AlekSi/pointer v1.1.0/go.mod h1:y7BvfRI3wXPWKXEBhU71nbnIEEZX0QTSB2Bj48UJIZE=
github.com/bwmarrin/discordgo v0.20.2 h1:nA7jiTtqUA9lT93WL2jPjUp8ZTEInRujBdx1C9gkr20= github.com/bwmarrin/discordgo v0.20.2 h1:nA7jiTtqUA9lT93WL2jPjUp8ZTEInRujBdx1C9gkr20=
github.com/bwmarrin/discordgo v0.20.2/go.mod h1:O9S4p+ofTFwB02em7jkpkV8M3R0/PUVOwN61zSZ0r4Q= github.com/bwmarrin/discordgo v0.20.2/go.mod h1:O9S4p+ofTFwB02em7jkpkV8M3R0/PUVOwN61zSZ0r4Q=
github.com/bwmarrin/discordgo v0.20.3-0.20200525154655-ca64123b05de h1:0TOVVwGrmv0PA+/vuekQIRY9jJ9rcHYnicIaph3/4S4= github.com/bwmarrin/discordgo v0.20.3-0.20200525154655-ca64123b05de h1:0TOVVwGrmv0PA+/vuekQIRY9jJ9rcHYnicIaph3/4S4=
github.com/bwmarrin/discordgo v0.20.3-0.20200525154655-ca64123b05de/go.mod h1:c1WtWUGN6nREDmzIpyTp/iD3VYt4Fpx+bVyfBG7JE+M= github.com/bwmarrin/discordgo v0.20.3-0.20200525154655-ca64123b05de/go.mod h1:c1WtWUGN6nREDmzIpyTp/iD3VYt4Fpx+bVyfBG7JE+M=
github.com/bwmarrin/discordgo v0.22.0 h1:uBxY1HmlVCsW1IuaPjpCGT6A2DBwRn0nvOguQIxDdFM= github.com/bwmarrin/discordgo v0.22.0 h1:uBxY1HmlVCsW1IuaPjpCGT6A2DBwRn0nvOguQIxDdFM=
github.com/bwmarrin/discordgo v0.22.0/go.mod h1:c1WtWUGN6nREDmzIpyTp/iD3VYt4Fpx+bVyfBG7JE+M= github.com/bwmarrin/discordgo v0.22.0/go.mod h1:c1WtWUGN6nREDmzIpyTp/iD3VYt4Fpx+bVyfBG7JE+M=
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/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -17,29 +21,48 @@ github.com/dustinpianalto/disgoman v0.0.14 h1:hsk56JATBE5eH5GPCDGeiTdYxok4m+edSY
github.com/dustinpianalto/disgoman v0.0.14/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= github.com/dustinpianalto/disgoman v0.0.14/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g=
github.com/dustinpianalto/disgoman v0.0.15 h1:kdIw6jhC82WBut7+4BarqxBw06dozU+Hu47LQzkkoGM= github.com/dustinpianalto/disgoman v0.0.15 h1:kdIw6jhC82WBut7+4BarqxBw06dozU+Hu47LQzkkoGM=
github.com/dustinpianalto/disgoman v0.0.15/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= github.com/dustinpianalto/disgoman v0.0.15/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g=
github.com/dustinpianalto/disgoman v0.0.21 h1:GfT149ymB/7BAJaKn4DNB66zBAbSB1tdn3E26NGok0o=
github.com/dustinpianalto/disgoman v0.0.21/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g=
github.com/dustinpianalto/rpnparse v1.0.1 h1:ZvH1/RIe5hh3RGSAXOgtngEDHNPTF+DMh88XFWpQjzY= github.com/dustinpianalto/rpnparse v1.0.1 h1:ZvH1/RIe5hh3RGSAXOgtngEDHNPTF+DMh88XFWpQjzY=
github.com/dustinpianalto/rpnparse v1.0.1/go.mod h1:SzFbQb+Eed5gYCtDu/SYEXXwdPtWkDg9oaL1xQtN1BY= github.com/dustinpianalto/rpnparse v1.0.1/go.mod h1:SzFbQb+Eed5gYCtDu/SYEXXwdPtWkDg9oaL1xQtN1BY=
github.com/emersion/go-imap v1.0.5 h1:8xg/d2wo2BBP3AEP5AOaM/6i8887RGyVW2st/IVHWUw= github.com/emersion/go-imap v1.0.5 h1:8xg/d2wo2BBP3AEP5AOaM/6i8887RGyVW2st/IVHWUw=
github.com/emersion/go-imap v1.0.5/go.mod h1:yKASt+C3ZiDAiCSssxg9caIckWF/JG7ZQTO7GAmvicU= github.com/emersion/go-imap v1.0.5/go.mod h1:yKASt+C3ZiDAiCSssxg9caIckWF/JG7ZQTO7GAmvicU=
github.com/emersion/go-imap v1.1.0 h1:hAW8Dbi/AwiVO5Wi40FTVuCzVrTmwtEK6De9GSoOy+Y=
github.com/emersion/go-imap v1.1.0/go.mod h1:0hCeak4mA2z9hICM20jeqN6fyV0Oad0lZTyeeAyUS6o=
github.com/emersion/go-message v0.11.1/go.mod h1:C4jnca5HOTo4bGN9YdqNQM9sITuT3Y0K6bSUw9RklvY= github.com/emersion/go-message v0.11.1/go.mod h1:C4jnca5HOTo4bGN9YdqNQM9sITuT3Y0K6bSUw9RklvY=
github.com/emersion/go-message v0.12.0 h1:mZnv35eZ6lB6EftTQBgYXspOH0FQdhpFhSUhA9i6/Zg= github.com/emersion/go-message v0.12.0 h1:mZnv35eZ6lB6EftTQBgYXspOH0FQdhpFhSUhA9i6/Zg=
github.com/emersion/go-message v0.12.0/go.mod h1:C4jnca5HOTo4bGN9YdqNQM9sITuT3Y0K6bSUw9RklvY= github.com/emersion/go-message v0.12.0/go.mod h1:C4jnca5HOTo4bGN9YdqNQM9sITuT3Y0K6bSUw9RklvY=
github.com/emersion/go-message v0.14.1/go.mod h1:N1JWdZQ2WRUalmdHAX308CWBq747VJ8oUorFI3VCBwU=
github.com/emersion/go-message v0.15.0 h1:urgKGqt2JAc9NFJcgncQcohHdiYb803YTH9OQwHBHIY=
github.com/emersion/go-message v0.15.0/go.mod h1:wQUEfE+38+7EW8p8aZ96ptg6bAb1iwdgej19uXASlE4=
github.com/emersion/go-sasl v0.0.0-20191210011802-430746ea8b9b h1:uhWtEWBHgop1rqEk2klKaxPAkVDCXexai6hSuRQ7Nvs= github.com/emersion/go-sasl v0.0.0-20191210011802-430746ea8b9b h1:uhWtEWBHgop1rqEk2klKaxPAkVDCXexai6hSuRQ7Nvs=
github.com/emersion/go-sasl v0.0.0-20191210011802-430746ea8b9b/go.mod h1:G/dpzLu16WtQpBfQ/z3LYiYJn3ZhKSGWn83fyoyQe/k= github.com/emersion/go-sasl v0.0.0-20191210011802-430746ea8b9b/go.mod h1:G/dpzLu16WtQpBfQ/z3LYiYJn3ZhKSGWn83fyoyQe/k=
github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21 h1:OJyUGMJTzHTd1XQp98QTaHernxMYzRaOasRir9hUlFQ=
github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21/go.mod h1:iL2twTeMvZnrg54ZoPDNfJaJaqy0xIQFuBdrLsmspwQ=
github.com/emersion/go-textwrapper v0.0.0-20160606182133-d0e65e56babe h1:40SWqY0zE3qCi6ZrtTf5OUdNm5lDnGnjRSq9GgmeTrg= github.com/emersion/go-textwrapper v0.0.0-20160606182133-d0e65e56babe h1:40SWqY0zE3qCi6ZrtTf5OUdNm5lDnGnjRSq9GgmeTrg=
github.com/emersion/go-textwrapper v0.0.0-20160606182133-d0e65e56babe/go.mod h1:aqO8z8wPrjkscevZJFVE1wXJrLpC5LtJG7fqLOsPb2U= github.com/emersion/go-textwrapper v0.0.0-20160606182133-d0e65e56babe/go.mod h1:aqO8z8wPrjkscevZJFVE1wXJrLpC5LtJG7fqLOsPb2U=
github.com/emersion/go-textwrapper v0.0.0-20200911093747-65d896831594 h1:IbFBtwoTQyw0fIM5xv1HF+Y+3ZijDR839WMulgxCcUY=
github.com/emersion/go-textwrapper v0.0.0-20200911093747-65d896831594/go.mod h1:aqO8z8wPrjkscevZJFVE1wXJrLpC5LtJG7fqLOsPb2U=
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= 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/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU= github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU=
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8=
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/martinlindhe/base36 v1.0.0 h1:eYsumTah144C0A8P1T/AVSUk5ZoLnhfYFM3OGQxB52A= github.com/martinlindhe/base36 v1.0.0 h1:eYsumTah144C0A8P1T/AVSUk5ZoLnhfYFM3OGQxB52A=
github.com/martinlindhe/base36 v1.0.0/go.mod h1:+AtEs8xrBpCeYgSLoY/aJ6Wf37jtBuR0s35750M27+8= github.com/martinlindhe/base36 v1.0.0/go.mod h1:+AtEs8xrBpCeYgSLoY/aJ6Wf37jtBuR0s35750M27+8=
github.com/martinlindhe/base36 v1.1.0 h1:cIwvvwYse/0+1CkUPYH5ZvVIYG3JrILmQEIbLuar02Y=
github.com/martinlindhe/base36 v1.1.0/go.mod h1:+AtEs8xrBpCeYgSLoY/aJ6Wf37jtBuR0s35750M27+8=
github.com/olebedev/when v0.0.0-20190311101825-c3b538a97254 h1:JYoQR67E1vv1WGoeW8DkdFs7vrIEe/5wP+qJItd5tUE= github.com/olebedev/when v0.0.0-20190311101825-c3b538a97254 h1:JYoQR67E1vv1WGoeW8DkdFs7vrIEe/5wP+qJItd5tUE=
github.com/olebedev/when v0.0.0-20190311101825-c3b538a97254/go.mod h1:DPucAeQGDPUzYUt+NaWw6qsF5SFapWWToxEiVDh2aV0= github.com/olebedev/when v0.0.0-20190311101825-c3b538a97254/go.mod h1:DPucAeQGDPUzYUt+NaWw6qsF5SFapWWToxEiVDh2aV0=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -47,6 +70,20 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16 h1:y6ce7gCWtnH+m3dCjzQ1PCuwl28DDIc3VNnvY29DlIA= golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16 h1:y6ce7gCWtnH+m3dCjzQ1PCuwl28DDIc3VNnvY29DlIA=
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/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-20210818153620-00dd8d7831e7 h1:/bmDWM82ZX7TawqxuI8kVjKI0TXHdSY6pHJArewwHtU=
golang.org/x/sys v0.0.0-20210818153620-00dd8d7831e7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5-0.20201125200606-c27b9fd57aec/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+1 -1
View File
@@ -32,7 +32,7 @@ func ParseDateString(inTime time.Time) string {
} else { } else {
dateString = "Now" dateString = "Now"
} }
stamp := inTime.Format("2006-01-02 15:04:05") stamp := inTime.Format("2006-01-02 15:04:05.000")
return fmt.Sprintf("%v\n%v", dateString, stamp) return fmt.Sprintf("%v\n%v", dateString, stamp)
} }
+4 -1
View File
@@ -19,7 +19,10 @@ func ParseSnowflake(s int64) Snowflake {
PROCESS_ID_MASK = 0x1F000 PROCESS_ID_MASK = 0x1F000
INCREMENT_MASK = 0xFFF INCREMENT_MASK = 0xFFF
) )
creationTime := time.Unix(((s>>TIME_BITS_LOC)+DISCORD_EPOCH)/1000.0, 0) t := (s >> TIME_BITS_LOC) + DISCORD_EPOCH
sec := t / 1000.0
nano := t % 1000.0 * 1000000.0
creationTime := time.Unix(sec, nano)
workerID := (s & WORKER_ID_MASK) >> WORKER_ID_LOC workerID := (s & WORKER_ID_MASK) >> WORKER_ID_LOC
processID := (s & PROCESS_ID_MASK) >> PROCESS_ID_LOC processID := (s & PROCESS_ID_MASK) >> PROCESS_ID_LOC
increment := s & INCREMENT_MASK increment := s & INCREMENT_MASK
+2 -2
View File
@@ -6,8 +6,8 @@ import (
"strings" "strings"
"github.com/dustinpianalto/disgoman" "github.com/dustinpianalto/disgoman"
"github.com/dustinpianalto/goff/internal/postgres" "gitea.wayfinderak.com/wayfinderak/goff/internal/postgres"
"github.com/dustinpianalto/goff/internal/services" "gitea.wayfinderak.com/wayfinderak/goff/internal/services"
) )
// Guild management commands // Guild management commands
@@ -5,7 +5,7 @@ import (
"log" "log"
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
"github.com/dustinpianalto/goff/internal/postgres" "gitea.wayfinderak.com/wayfinderak/goff/internal/postgres"
) )
func OnMessageUpdate(session *discordgo.Session, m *discordgo.MessageUpdate) { func OnMessageUpdate(session *discordgo.Session, m *discordgo.MessageUpdate) {
@@ -29,6 +29,9 @@ func OnMessageUpdate(session *discordgo.Session, m *discordgo.MessageUpdate) {
log.Println(err) log.Println(err)
return return
} }
if m.Content == "" {
return
}
embed := &discordgo.MessageEmbed{ embed := &discordgo.MessageEmbed{
Title: fmt.Sprintf("Message Edited: %v", msg.ID), Title: fmt.Sprintf("Message Edited: %v", msg.ID),
Description: fmt.Sprintf("**Before:** %v\n**After:** %v\nIn Channel: %v", msg.Content, m.Content, channel.Mention()), Description: fmt.Sprintf("**Before:** %v\n**After:** %v\nIn Channel: %v", msg.Content, m.Content, channel.Mention()),
+9 -8
View File
@@ -2,15 +2,15 @@ package exts
import ( import (
"github.com/dustinpianalto/disgoman" "github.com/dustinpianalto/disgoman"
"github.com/dustinpianalto/goff/internal/exts/fun" "gitea.wayfinderak.com/wayfinderak/goff/internal/exts/fun"
"github.com/dustinpianalto/goff/internal/exts/guild_management" "gitea.wayfinderak.com/wayfinderak/goff/internal/exts/guild_management"
"github.com/dustinpianalto/goff/internal/exts/roles" "gitea.wayfinderak.com/wayfinderak/goff/internal/exts/roles"
"github.com/dustinpianalto/goff/internal/exts/tags" "gitea.wayfinderak.com/wayfinderak/goff/internal/exts/tags"
"github.com/dustinpianalto/goff/internal/exts/tasks" "gitea.wayfinderak.com/wayfinderak/goff/internal/exts/tasks"
"github.com/dustinpianalto/goff/internal/exts/user_management" "gitea.wayfinderak.com/wayfinderak/goff/internal/exts/user_management"
"github.com/dustinpianalto/goff/internal/exts/utils" "gitea.wayfinderak.com/wayfinderak/goff/internal/exts/utils"
"github.com/dustinpianalto/goff/internal/exts/p_interpreter" "gitea.wayfinderak.com/wayfinderak/goff/internal/exts/p_interpreter"
) )
func AddCommandHandlers(h *disgoman.CommandManager) { func AddCommandHandlers(h *disgoman.CommandManager) {
@@ -27,6 +27,7 @@ func AddCommandHandlers(h *disgoman.CommandManager) {
_ = h.AddCommand(utils.GitCommand) _ = h.AddCommand(utils.GitCommand)
_ = h.AddCommand(utils.InviteCommand) _ = h.AddCommand(utils.InviteCommand)
_ = h.AddCommand(utils.PingCommand) _ = h.AddCommand(utils.PingCommand)
_ = h.AddCommand(utils.SnowflakeCommand)
_ = h.AddCommand(tasks.AddReminderCommand) _ = h.AddCommand(tasks.AddReminderCommand)
_ = h.AddCommand(tags.AddTagCommand) _ = h.AddCommand(tags.AddTagCommand)
_ = h.AddCommand(tags.TagCommand) _ = h.AddCommand(tags.TagCommand)
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
"github.com/dustinpianalto/goff/internal/postgres" "gitea.wayfinderak.com/wayfinderak/goff/internal/postgres"
) )
var LoggingChannel = make(chan *LogEvent, 10) var LoggingChannel = make(chan *LogEvent, 10)
+3 -3
View File
@@ -7,9 +7,9 @@ import (
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
"github.com/dustinpianalto/disgoman" "github.com/dustinpianalto/disgoman"
"github.com/dustinpianalto/goff" "gitea.wayfinderak.com/wayfinderak/goff"
"github.com/dustinpianalto/goff/internal/postgres" "gitea.wayfinderak.com/wayfinderak/goff/internal/postgres"
"github.com/dustinpianalto/goff/internal/services" "gitea.wayfinderak.com/wayfinderak/goff/internal/services"
) )
var MakeRoleSelfAssignableCommand = &disgoman.Command{ var MakeRoleSelfAssignableCommand = &disgoman.Command{
+3 -3
View File
@@ -7,9 +7,9 @@ import (
"strings" "strings"
"github.com/dustinpianalto/disgoman" "github.com/dustinpianalto/disgoman"
"github.com/dustinpianalto/goff" "gitea.wayfinderak.com/wayfinderak/goff"
"github.com/dustinpianalto/goff/internal/postgres" "gitea.wayfinderak.com/wayfinderak/goff/internal/postgres"
"github.com/dustinpianalto/goff/internal/services" "gitea.wayfinderak.com/wayfinderak/goff/internal/services"
) )
var AddTagCommand = &disgoman.Command{ var AddTagCommand = &disgoman.Command{
+2 -1
View File
@@ -6,7 +6,7 @@ import (
"time" "time"
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
"github.com/dustinpianalto/goff/internal/postgres" "gitea.wayfinderak.com/wayfinderak/goff/internal/postgres"
) )
type Task struct { type Task struct {
@@ -100,6 +100,7 @@ func getTasksToRun() []Task {
res, err := postgres.DB.Query(query, time.Now()) res, err := postgres.DB.Query(query, time.Now())
if err != nil { if err != nil {
log.Println(err) log.Println(err)
return nil
} }
var tasks []Task var tasks []Task
for res.Next() { for res.Next() {
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"time" "time"
"github.com/dustinpianalto/disgoman" "github.com/dustinpianalto/disgoman"
"github.com/dustinpianalto/goff/internal/postgres" "gitea.wayfinderak.com/wayfinderak/goff/internal/postgres"
"github.com/olebedev/when" "github.com/olebedev/when"
"github.com/olebedev/when/rules/common" "github.com/olebedev/when/rules/common"
"github.com/olebedev/when/rules/en" "github.com/olebedev/when/rules/en"
+31 -2
View File
@@ -4,8 +4,8 @@ import (
"log" "log"
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
"github.com/dustinpianalto/goff" "gitea.wayfinderak.com/wayfinderak/goff"
"github.com/dustinpianalto/goff/internal/services" "gitea.wayfinderak.com/wayfinderak/goff/internal/services"
) )
func OnGuildMemberAdd(s *discordgo.Session, member *discordgo.GuildMemberAdd) { func OnGuildMemberAdd(s *discordgo.Session, member *discordgo.GuildMemberAdd) {
@@ -41,6 +41,7 @@ func OnGuildMemberAdd(s *discordgo.Session, member *discordgo.GuildMemberAdd) {
if err != nil { if err != nil {
log.Println("Error adding user to guild: ", err) log.Println("Error adding user to guild: ", err)
} }
if !member.Member.Pending {
roles, err := services.RoleService.GetAutoRoles(member.GuildID) roles, err := services.RoleService.GetAutoRoles(member.GuildID)
if err != nil { if err != nil {
log.Println("Error getting Auto Join Roles: ", err) log.Println("Error getting Auto Join Roles: ", err)
@@ -58,6 +59,7 @@ func OnGuildMemberAdd(s *discordgo.Session, member *discordgo.GuildMemberAdd) {
continue continue
} }
} }
}
} }
func OnGuildMemberRemove(s *discordgo.Session, member *discordgo.GuildMemberRemove) { func OnGuildMemberRemove(s *discordgo.Session, member *discordgo.GuildMemberRemove) {
@@ -88,3 +90,30 @@ func OnGuildMemberRemove(s *discordgo.Session, member *discordgo.GuildMemberRemo
} }
} }
} }
func OnGuildMemberUpdate(s *discordgo.Session, member *discordgo.GuildMemberUpdate) {
defer func() {
if r := recover(); r != nil {
log.Println("Recovered from panic in OnGuildMemberUpdate: ", r)
}
}()
if !member.Member.Pending {
roles, err := services.RoleService.GetAutoRoles(member.GuildID)
if err != nil {
log.Println("Error getting Auto Join Roles: ", err)
}
log.Println(roles)
for _, r := range roles {
role, err := s.State.Role(member.GuildID, r.ID)
if err != nil {
log.Println("Error getting role: ", err)
continue
}
err = s.GuildMemberRoleAdd(member.GuildID, member.User.ID, role.ID)
if err != nil {
log.Println("Error adding Role to member: ", err)
continue
}
}
}
}
@@ -7,8 +7,8 @@ import (
"time" "time"
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
"github.com/dustinpianalto/goff/internal/discord_utils" "gitea.wayfinderak.com/wayfinderak/goff/internal/discord_utils"
"github.com/dustinpianalto/goff/internal/postgres" "gitea.wayfinderak.com/wayfinderak/goff/internal/postgres"
) )
func OnGuildMemberAddLogging(s *discordgo.Session, member *discordgo.GuildMemberAdd) { func OnGuildMemberAddLogging(s *discordgo.Session, member *discordgo.GuildMemberAdd) {
@@ -163,5 +163,4 @@ func MarkMemberInactive(s *discordgo.Session, m *discordgo.GuildMemberRemove) {
log.Println(fmt.Errorf("error marking %s as inactive: %w", m.User.ID, err)) log.Println(fmt.Errorf("error marking %s as inactive: %w", m.User.ID, err))
return return
} }
log.Println("User left: %s")
} }
@@ -8,7 +8,7 @@ import (
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
"github.com/dustinpianalto/disgoman" "github.com/dustinpianalto/disgoman"
"github.com/dustinpianalto/goff/internal/exts/logging" "gitea.wayfinderak.com/wayfinderak/goff/internal/exts/logging"
) )
var KickUserCommand = &disgoman.Command{ var KickUserCommand = &disgoman.Command{
+32 -3
View File
@@ -9,7 +9,7 @@ import (
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
"github.com/dustinpianalto/disgoman" "github.com/dustinpianalto/disgoman"
"github.com/dustinpianalto/goff/internal/discord_utils" "gitea.wayfinderak.com/wayfinderak/goff/internal/discord_utils"
) )
var PingCommand = &disgoman.Command{ var PingCommand = &disgoman.Command{
@@ -80,9 +80,9 @@ var GitCommand = &disgoman.Command{
func gitCommandFunc(ctx disgoman.Context, _ []string) { func gitCommandFunc(ctx disgoman.Context, _ []string) {
embed := &discordgo.MessageEmbed{ embed := &discordgo.MessageEmbed{
Title: "Hi there, My code is on Github", Title: "Hi there, my code is on Gitea",
Color: 0, Color: 0,
URL: "https://github.com/dustinpianalto/Goff", URL: "https://gitea.wayfinderak.com/wayfinderak/goff",
} }
_, err := ctx.Session.ChannelMessageSendEmbed(ctx.Channel.ID, embed) _, err := ctx.Session.ChannelMessageSendEmbed(ctx.Channel.ID, embed)
if err != nil { if err != nil {
@@ -218,3 +218,32 @@ func userCommandFunc(ctx disgoman.Context, args []string) {
} }
} }
} }
var SnowflakeCommand = &disgoman.Command{
Name: "s",
Aliases: nil,
Description: "Return the parts of a snowflake",
OwnerOnly: false,
Hidden: false,
RequiredPermissions: 0,
SanitizeEveryone: true,
Invoke: snowflakeCommandFunc,
}
func snowflakeCommandFunc(ctx disgoman.Context, args []string) {
int64ID, err := strconv.ParseInt(args[0], 10, 64)
if err != nil {
ctx.CommandManager.ErrorChannel <- disgoman.CommandError{
Context: ctx,
Message: "Not a valid ID",
Error: err,
}
return
}
s := discord_utils.ParseSnowflake(int64ID)
embed := &discordgo.MessageEmbed{
Title: args[0],
Description: fmt.Sprintf("Created: %s\nWorker: %d\nProcess: %d\nCounter: %d", discord_utils.ParseDateString(s.CreationTime), s.WorkerID, s.ProcessID, s.Increment),
}
_, _ = ctx.Session.ChannelMessageSendEmbed(ctx.Channel.ID, embed)
}
+26 -19
View File
@@ -4,6 +4,7 @@ import (
"database/sql" "database/sql"
"fmt" "fmt"
"log" "log"
"time"
_ "github.com/lib/pq" _ "github.com/lib/pq"
) )
@@ -16,17 +17,23 @@ func ConnectDatabase(dbConnString string) {
db, err := sql.Open("postgres", dbConnString) db, err := sql.Open("postgres", dbConnString)
if err != nil { if err != nil {
panic(fmt.Sprintf("Can't connect to the database. %v", err)) panic(fmt.Sprintf("Can't connect to the database. %v", err))
} else {
fmt.Println("Database Connected.")
} }
db.SetMaxOpenConns(75) // The RDS instance has a max of 75 open connections
db.SetMaxIdleConns(5) db.SetMaxOpenConns(5)
db.SetConnMaxLifetime(300) db.SetMaxIdleConns(2)
db.SetConnMaxLifetime(30 * time.Minute)
db.SetConnMaxIdleTime(5 * time.Minute)
if err = db.Ping(); err != nil {
panic(fmt.Sprintf("Can't ping the database. %v", err))
}
fmt.Println("Database Connected.")
DB = db DB = db
} }
func InitializeDatabase() { func InitializeDatabase() {
_, err := DB.Query("CREATE TABLE IF NOT EXISTS users(" + _, err := DB.Exec("CREATE TABLE IF NOT EXISTS users(" +
"id varchar(30) primary key," + "id varchar(30) primary key," +
"banned bool not null default false," + "banned bool not null default false," +
"logging bool not null default true," + "logging bool not null default true," +
@@ -38,7 +45,7 @@ func InitializeDatabase() {
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} }
_, err = DB.Query("CREATE TABLE IF NOT EXISTS guilds(" + _, err = DB.Exec("CREATE TABLE IF NOT EXISTS guilds(" +
"id varchar(30) primary key," + "id varchar(30) primary key," +
"welcome_message varchar(1000) NOT NULL DEFAULT ''," + "welcome_message varchar(1000) NOT NULL DEFAULT ''," +
"goodbye_message varchar(1000) NOT NULL DEFAULT ''," + "goodbye_message varchar(1000) NOT NULL DEFAULT ''," +
@@ -48,14 +55,14 @@ func InitializeDatabase() {
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} }
_, err = DB.Query("CREATE TABLE IF NOT EXISTS prefixes(" + _, err = DB.Exec("CREATE TABLE IF NOT EXISTS prefixes(" +
"id serial primary key," + "id serial primary key," +
"prefix varchar(10) not null unique default 'Go.'" + "prefix varchar(10) not null unique default 'Go.'" +
")") ")")
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} }
_, err = DB.Query("CREATE TABLE IF NOT EXISTS tags(" + _, err = DB.Exec("CREATE TABLE IF NOT EXISTS tags(" +
"id serial primary key," + "id serial primary key," +
"tag varchar(100) not null unique," + "tag varchar(100) not null unique," +
"content varchar(1000) not null," + "content varchar(1000) not null," +
@@ -66,21 +73,21 @@ func InitializeDatabase() {
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} }
_, err = DB.Query("CREATE TABLE IF NOT EXISTS x_users_guilds(" + _, err = DB.Exec("CREATE TABLE IF NOT EXISTS x_users_guilds(" +
"guild_id varchar(30) not null references guilds(id)," + "guild_id varchar(30) not null references guilds(id)," +
"user_id varchar(30) not null references users(id)" + "user_id varchar(30) not null references users(id)" +
")") ")")
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} }
_, err = DB.Query("CREATE TABLE IF NOT EXISTS x_guilds_prefixes(" + _, err = DB.Exec("CREATE TABLE IF NOT EXISTS x_guilds_prefixes(" +
"guild_id varchar(30) not null references guilds(id)," + "guild_id varchar(30) not null references guilds(id)," +
"prefix_id int not null references prefixes(id)" + "prefix_id int not null references prefixes(id)" +
")") ")")
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} }
_, err = DB.Query("CREATE TABLE IF NOT EXISTS tasks(" + _, err = DB.Exec("CREATE TABLE IF NOT EXISTS tasks(" +
"id serial primary key," + "id serial primary key," +
"type varchar(10) not null," + "type varchar(10) not null," +
"content text not null," + "content text not null," +
@@ -94,7 +101,7 @@ func InitializeDatabase() {
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} }
_, err = DB.Query(`CREATE TABLE IF NOT EXISTS postfixes( _, err = DB.Exec(`CREATE TABLE IF NOT EXISTS postfixes(
id serial primary key, id serial primary key,
name varchar(100) not null, name varchar(100) not null,
time timestamp not null default NOW())`) time timestamp not null default NOW())`)
@@ -119,37 +126,37 @@ func InitializeDatabase() {
} }
func LoadTestData() { func LoadTestData() {
_, err := DB.Query("INSERT INTO users (id, banned, logging, steam_id, is_active, is_staff, is_admin) values " + _, err := DB.Exec("INSERT INTO users (id, banned, logging, steam_id, is_active, is_staff, is_admin) values " +
"('351794468870946827', false, true, '76561198024193239', true, true, true)," + "('351794468870946827', false, true, '76561198024193239', true, true, true)," +
"('692908139506434065', false, true, '', true, false, false)," + "('692908139506434065', false, true, '', true, false, false)," +
"('396588996706304010', false, true, '', true, true, false)") "('396588996706304010', false, true, '', true, true, false)")
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} }
_, err = DB.Query("INSERT INTO guilds (id, welcome_message, goodbye_message) VALUES " + _, err = DB.Exec("INSERT INTO guilds (id, welcome_message, goodbye_message) VALUES " +
"('265828729970753537', 'Hey there is someone new here.', 'Well fine then... Just leave without saying goodbye')") "('265828729970753537', 'Hey there is someone new here.', 'Well fine then... Just leave without saying goodbye')")
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} }
_, err = DB.Query("INSERT INTO prefixes (prefix) VALUES ('Godev.'), ('godev.'), ('godev,')") _, err = DB.Exec("INSERT INTO prefixes (prefix) VALUES ('Godev.'), ('godev.'), ('godev,')")
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} }
_, err = DB.Query("INSERT INTO x_users_guilds (guild_id, user_id) VALUES " + _, err = DB.Exec("INSERT INTO x_users_guilds (guild_id, user_id) VALUES " +
"('265828729970753537', '351794468870946827')," + "('265828729970753537', '351794468870946827')," +
"('265828729970753537', '692908139506434065')," + "('265828729970753537', '692908139506434065')," +
"('265828729970753537', '396588996706304010')") "('265828729970753537', '396588996706304010')")
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} }
_, err = DB.Query("INSERT INTO x_guilds_prefixes (guild_id, prefix_id) VALUES " + _, err = DB.Exec("INSERT INTO x_guilds_prefixes (guild_id, prefix_id) VALUES " +
"('265828729970753537', 1)," + "('265828729970753537', 1)," +
"('265828729970753537', 2)," + "('265828729970753537', 2)," +
"('265828729970753537', 3)") "('265828729970753537', 3)")
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} }
_, err = DB.Query("INSERT INTO tags (tag, content, creator, guild_id) VALUES " + _, err = DB.Exec("INSERT INTO tags (tag, content, creator, guild_id) VALUES " +
"('test', 'This is a test of the tag system', '351794468870946827', '265828729970753537')") "('test', 'This is a test of the tag system', '351794468870946827', '265828729970753537')")
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"database/sql" "database/sql"
"log" "log"
"github.com/dustinpianalto/goff" "gitea.wayfinderak.com/wayfinderak/goff"
) )
type GuildService struct { type GuildService struct {
+2
View File
@@ -47,8 +47,10 @@ func RunPostfixes() {
continue continue
} }
if rows.Next() { if rows.Next() {
rows.Close()
continue continue
} else { } else {
rows.Close()
err := postfix.Invoke(false) err := postfix.Invoke(false)
if err != nil { if err != nil {
continue continue
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"database/sql" "database/sql"
"log" "log"
"github.com/dustinpianalto/goff" "gitea.wayfinderak.com/wayfinderak/goff"
) )
type RoleService struct { type RoleService struct {
+1 -1
View File
@@ -3,7 +3,7 @@ package postgres
import ( import (
"database/sql" "database/sql"
"github.com/dustinpianalto/goff" "gitea.wayfinderak.com/wayfinderak/goff"
) )
type UserService struct { type UserService struct {
+1 -1
View File
@@ -1,6 +1,6 @@
package services package services
import "github.com/dustinpianalto/goff" import "gitea.wayfinderak.com/wayfinderak/goff"
var UserService goff.UserService var UserService goff.UserService
var GuildService goff.GuildService var GuildService goff.GuildService
+1 -1
View File
@@ -9,7 +9,7 @@ import (
"time" "time"
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
"github.com/dustinpianalto/goff/pkg/puzzles" "gitea.wayfinderak.com/wayfinderak/goff/pkg/puzzles"
imap "github.com/emersion/go-imap" imap "github.com/emersion/go-imap"
"github.com/emersion/go-imap/client" "github.com/emersion/go-imap/client"
"github.com/emersion/go-message/mail" "github.com/emersion/go-message/mail"
+2 -2
View File
@@ -8,8 +8,8 @@ import (
"time" "time"
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
"github.com/dustinpianalto/goff" "gitea.wayfinderak.com/wayfinderak/goff"
"github.com/dustinpianalto/goff/internal/postgres" "gitea.wayfinderak.com/wayfinderak/goff/internal/postgres"
"github.com/emersion/go-message/mail" "github.com/emersion/go-message/mail"
) )
+4
View File
@@ -0,0 +1,4 @@
DATABASE_URL=postgresql://goff:DCkTm6Nns9hi8j@10.0.0.202:5432/goff
DISCORDGO_TOKEN=NjkyOTA4MTM5NTA2NDM0MDY1.Xn1W_g.SKCxfilgBc2PFCYvK2pXhqme_fc
GOFF_EMAIL_USERNAME=goff@djpianalto.com
GOFF_EMAIL_PASSWORD=1MzV9VU8u4J2
+9
View File
@@ -0,0 +1,9 @@
services:
goff:
image: gitea.wayfinderak.com/wayfinderak/goff:latest
container_name: goff
restart: unless-stopped
env_file:
- ./portainer-app.env
mem_limit: 1g
cpus: "2.0"