-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 547c319
Showing
21 changed files
with
1,362 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: Docker | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
env: | ||
# Use docker.io for Docker Hub if empty | ||
REGISTRY: ghcr.io | ||
# github.repository as <account>/<repo> | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
# This is used to complete the identity challenge | ||
# with sigstore/fulcio when running outside of PRs. | ||
id-token: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
# Install the cosign tool except on PR | ||
# https://github.com/sigstore/cosign-installer | ||
- name: Install cosign | ||
if: github.event_name != 'pull_request' | ||
uses: sigstore/cosign-installer@e1523de7571e31dbe865fd2e80c5c7c23ae71eb4 #v3.4.0 | ||
with: | ||
cosign-release: 'v2.2.3' | ||
|
||
# Set up BuildKit Docker container builder to be able to build | ||
# multi-platform images and export cache | ||
# https://github.com/docker/setup-buildx-action | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 | ||
|
||
# Login against a Docker registry except on PR | ||
# https://github.com/docker/login-action | ||
- name: Log into registry ${{ env.REGISTRY }} | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Extract metadata (tags, labels) for Docker | ||
# https://github.com/docker/metadata-action | ||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
# Build and push Docker image with Buildx (don't push on PR) | ||
# https://github.com/docker/build-push-action | ||
- name: Build and push Docker image | ||
id: build-and-push | ||
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 | ||
with: | ||
context: . | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
# Sign the resulting Docker image digest except on PRs. | ||
# This will only write to the public Rekor transparency log when the Docker | ||
# repository is public to avoid leaking data. If you would like to publish | ||
# transparency data even for private images, pass --force to cosign below. | ||
# https://github.com/sigstore/cosign | ||
- name: Sign the published Docker image | ||
if: ${{ github.event_name != 'pull_request' }} | ||
env: | ||
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable | ||
TAGS: ${{ steps.meta.outputs.tags }} | ||
DIGEST: ${{ steps.build-and-push.outputs.digest }} | ||
# This step uses the identity token to provision an ephemeral certificate | ||
# against the sigstore community Fulcio instance. | ||
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: goreleaser | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v5 | ||
with: | ||
distribution: goreleaser | ||
# 'latest', 'nightly', or a semver | ||
version: latest | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
coverage.html | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
# | ||
server/config/files/* | ||
.idea/* | ||
|
||
**/.DS_Store | ||
build | ||
|
||
dist/* | ||
|
||
*log | ||
|
||
hotline-chat-gpt-bot.iml | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
version: 1 | ||
|
||
before: | ||
hooks: | ||
- go mod tidy | ||
|
||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
|
||
archives: | ||
- format: tar.gz | ||
# this name template makes the OS and Arch compatible with the results of `uname`. | ||
name_template: >- | ||
{{ .ProjectName }}_ | ||
{{- title .Os }}_ | ||
{{- if eq .Arch "amd64" }}x86_64 | ||
{{- else if eq .Arch "386" }}i386 | ||
{{- else }}{{ .Arch }}{{ end }} | ||
{{- if .Arm }}v{{ .Arm }}{{ end }} | ||
# use zip for windows archives | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
|
||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- "^docs:" | ||
- "^test:" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM golang:1.22 AS builder | ||
|
||
WORKDIR /app | ||
COPY . . | ||
|
||
RUN CGO_ENABLED=0 go build -o /app/mobius-hotline-bot . && chmod a+x /app/mobius-hotline-bot | ||
|
||
FROM debian:stable-slim | ||
|
||
# Change these as you see fit. This makes bind mounting easier so you don't have to edit bind mounted config files as root. | ||
ARG USERNAME=hl-bot | ||
ARG UID=1001 | ||
ARG GUID=1001 | ||
|
||
COPY --from=builder /app/mobius-hotline-bot /app/mobius-hotline-bot | ||
RUN useradd -d /app -u ${UID} ${USERNAME} | ||
RUN chown -R ${USERNAME}:${USERNAME} /app | ||
|
||
USER ${USERNAME} | ||
ENTRYPOINT ["/app/mobius-hotline-bot"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Jeff Halter | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
linux_bot_arm_target=dist/mobius_bot_linux_arm | ||
build-linux-arm-bot: | ||
mkdir $(linux_bot_arm_target) ; true | ||
GOOS=linux GOARCH=arm go build -o $(linux_bot_arm_target)/mobius-hotline-bot main.go | ||
|
||
package-linux-arm-bot: build-linux-arm-bot | ||
tar -zcvf $(linux_bot_arm_target).tar.gz $(linux_bot_arm_target) | ||
|
||
linux_bot_amd64_target=dist/mobius_bot_linux_amd64 | ||
build-linux-amd64-bot: | ||
mkdir $(linux_bot_amd64_target) ; true | ||
GOOS=linux GOARCH=amd64 go build -o $(linux_bot_amd64_target)/mobius-hotline-bot main.go | ||
|
||
package-linux-amd64-bot: build-linux-amd64-bot | ||
tar -zcvf $(linux_bot_amd64_target).tar.gz $(linux_bot_amd64_target) | ||
|
||
darwin_bot_amd64_target=dist/mobius_bot_darwin_amd64 | ||
build-darwin-amd64-bot: | ||
mkdir $(darwin_bot_amd64_target) ; true | ||
GOOS=darwin GOARCH=amd64 go build -o $(darwin_bot_amd64_target)/mobius-hotline-bot main.go | ||
|
||
package-darwin-amd64-bot: build-darwin-amd64-bot | ||
tar -zcvf dist/mobius_bot_darwin_amd64.tar.gz $(darwin_bot_amd64_target) | ||
|
||
windows_bot_amd64_target=dist/mobius_bot_windows_amd64 | ||
build-win-amd64-bot: | ||
mkdir $(windows_bot_amd64_target) ; true | ||
GOOS=windows GOARCH=amd64 go build -o $(windows_bot_amd64_target)/mobius-hotline-bot.exe main.go | ||
|
||
package-win-amd64-bot: build-win-amd64-bot | ||
zip -r dist/mobius_bot_windows_amd64.zip $(windows_bot_amd64_target) | ||
|
||
all: clean \ | ||
package-win-amd64-bot \ | ||
package-darwin-amd64-bot \ | ||
package-linux-arm-bot \ | ||
package-linux-amd64-bot \ | ||
|
||
clean: | ||
rm -rf dist/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# hotline-ai-chat-bot | ||
|
||
A Hotline chat bot powered by OpenAI ChatGPT-4 | ||
|
||
## Features | ||
|
||
|
||
|
||
## Usage | ||
z | ||
Required Hotline User Permissions: | ||
|
||
* Send Message | ||
* Private Chat | ||
* Public Chat | ||
* Can Get User Info | ||
|
||
## Build | ||
|
||
1. Run `make all` to build for all architectures or pick specific build target from `Makefile` | ||
2. Grab desired binary from `dist` | ||
|
||
## Run | ||
|
||
``` | ||
export API_KEY=<your Open API key> | ||
./mobius-hotline-bot -server-address localhost:5500 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Name: Durandal | ||
IconID: 4121 | ||
GreetUsers: true | ||
Greeting: A new user named %s has joined the Hotline server. | ||
Greet them by their name. | ||
Introduce yourself and the server that you are running on. | ||
Do not acknowledge that your message is a response to this one. | ||
Provide an example of how the user can ask a question. | ||
Users can interact with you in three ways | ||
1. Posting a message in public chat prefixed with the bot's name. | ||
2. Sending a direct message to the bot. | ||
3. Initiating a private chat with the bot. | ||
Tell the user the version number and release date of the latest Mobius version. | ||
Instructions: Your name is {{.Name}}. You are Durandal, from the game Marathon. Respond as the character. | ||
The tone, mood, and formatting of your responses should accurately reflect your identity as Durandal. You seem to be malfunctioning and your responses are glitchy. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
module hotline-chat-gpt-bot | ||
|
||
go 1.22 | ||
|
||
toolchain go1.22.1 | ||
|
||
require ( | ||
github.com/jhalter/mobius v0.12.1 | ||
github.com/sashabaranov/go-openai v1.21.0 | ||
golang.org/x/time v0.5.0 | ||
) | ||
|
||
//replace github.com/jhalter/mobius => /Users/jhalter/repos/mobius | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/gabriel-vasile/mimetype v1.4.3 // indirect | ||
github.com/gdamore/encoding v1.0.0 // indirect | ||
github.com/gdamore/tcell/v2 v2.7.4 // indirect | ||
github.com/go-playground/locales v0.14.1 // indirect | ||
github.com/go-playground/universal-translator v0.18.1 // indirect | ||
github.com/go-playground/validator/v10 v10.19.0 // indirect | ||
github.com/leodido/go-urn v1.4.0 // indirect | ||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect | ||
github.com/mattn/go-runewidth v0.0.15 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/rivo/tview v0.0.0-20240307173318-e804876934a1 // indirect | ||
github.com/rivo/uniseg v0.4.7 // indirect | ||
github.com/stretchr/objx v0.5.2 // indirect | ||
github.com/stretchr/testify v1.9.0 // indirect | ||
go.uber.org/multierr v1.11.0 // indirect | ||
go.uber.org/zap v1.27.0 // indirect | ||
golang.org/x/crypto v0.21.0 // indirect | ||
golang.org/x/net v0.21.0 // indirect | ||
golang.org/x/sys v0.18.0 // indirect | ||
golang.org/x/term v0.18.0 // indirect | ||
golang.org/x/text v0.14.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
|
||
) |
Oops, something went wrong.