Rename bridge to go-groupme

This commit is contained in:
Annie Elequin 2021-09-16 14:44:40 -04:00
parent 2c154762fe
commit cce801604b
19 changed files with 22 additions and 430 deletions

View File

@ -13,13 +13,13 @@ stages:
- export GOPATH="$CI_PROJECT_DIR/.cache" - export GOPATH="$CI_PROJECT_DIR/.cache"
- export GOCACHE="$CI_PROJECT_DIR/.cache/build" - export GOCACHE="$CI_PROJECT_DIR/.cache/build"
- export GO_LDFLAGS="-linkmode external -extldflags -static -X main.Tag=$CI_COMMIT_TAG -X main.Commit=$CI_COMMIT_SHA -X 'main.BuildTime=`date '+%b %_d %Y, %H:%M:%S'`'" - export GO_LDFLAGS="-linkmode external -extldflags -static -X main.Tag=$CI_COMMIT_TAG -X main.Commit=$CI_COMMIT_SHA -X 'main.BuildTime=`date '+%b %_d %Y, %H:%M:%S'`'"
- git clone https://github.com/karmanyaahm/groupme.git ./groupme - git clone https://gitlab.com/beeper/groupme ./groupme
- git clone https://github.com/karmanyaahm/mautrix-go.git ./mautrix - git clone https://github.com/karmanyaahm/mautrix-go.git ./mautrix
script: script:
- go build -ldflags "$GO_LDFLAGS" -o mautrix-groupme - go build -ldflags "$GO_LDFLAGS" -o go-groupme
artifacts: artifacts:
paths: paths:
- mautrix-groupme - go-groupme
- example-config.yaml - example-config.yaml
.build-docker: &build-docker .build-docker: &build-docker

View File

@ -1,30 +1,20 @@
FROM golang:1-alpine3.12 AS builder FROM golang:1-alpine3.14 AS builder
RUN echo $'\
@edge http://dl-cdn.alpinelinux.org/alpine/edge/main\n\
@edge http://dl-cdn.alpinelinux.org/alpine/edge/testing\n\
@edge http://dl-cdn.alpinelinux.org/alpine/edge/community' >> /etc/apk/repositories
RUN apk add --no-cache git ca-certificates build-base su-exec olm-dev RUN apk add --no-cache git ca-certificates build-base su-exec olm-dev
COPY . /build COPY . /build
WORKDIR /build WORKDIR /build
RUN go build -o /usr/bin/mautrix-groupme RUN go build -o /usr/bin/go-groupme
FROM alpine:3.12 FROM alpine:3.14
RUN echo $'\
@edge http://dl-cdn.alpinelinux.org/alpine/edge/main\n\
@edge http://dl-cdn.alpinelinux.org/alpine/edge/testing\n\
@edge http://dl-cdn.alpinelinux.org/alpine/edge/community' >> /etc/apk/repositories
ENV UID=1337 \ ENV UID=1337 \
GID=1337 GID=1337
RUN apk add --no-cache ffmpeg su-exec ca-certificates olm bash jq yq@edge curl RUN apk add --no-cache ffmpeg su-exec ca-certificates olm bash jq yq curl
COPY --from=builder /usr/bin/mautrix-groupme /usr/bin/mautrix-groupme COPY --from=builder /usr/bin/go-groupme /usr/bin/go-groupme
COPY --from=builder /build/example-config.yaml /opt/mautrix-groupme/example-config.yaml COPY --from=builder /build/example-config.yaml /opt/go-groupme/example-config.yaml
COPY --from=builder /build/docker-run.sh /docker-run.sh COPY --from=builder /build/docker-run.sh /docker-run.sh
VOLUME /data VOLUME /data

View File

@ -1,18 +1,13 @@
FROM alpine:3.12 FROM alpine:3.14
RUN echo $'\
@edge http://dl-cdn.alpinelinux.org/alpine/edge/main\n\
@edge http://dl-cdn.alpinelinux.org/alpine/edge/testing\n\
@edge http://dl-cdn.alpinelinux.org/alpine/edge/community' >> /etc/apk/repositories
ENV UID=1337 \ ENV UID=1337 \
GID=1337 GID=1337
RUN apk add --no-cache ffmpeg su-exec ca-certificates bash jq curl yq@edge RUN apk add --no-cache ffmpeg su-exec ca-certificates bash jq curl yq
ARG EXECUTABLE=./mautrix-groupme ARG EXECUTABLE=./go-groupme
COPY $EXECUTABLE /usr/bin/mautrix-groupme COPY $EXECUTABLE /usr/bin/go-groupme
COPY ./example-config.yaml /opt/mautrix-groupme/example-config.yaml COPY ./example-config.yaml /opt/go-groupme/example-config.yaml
COPY ./docker-run.sh /docker-run.sh COPY ./docker-run.sh /docker-run.sh
VOLUME /data VOLUME /data

View File

@ -80,7 +80,7 @@ type Config struct {
func (config *Config) setDefaults() { func (config *Config) setDefaults() {
config.AppService.Database.MaxOpenConns = 20 config.AppService.Database.MaxOpenConns = 20
config.AppService.Database.MaxIdleConns = 2 config.AppService.Database.MaxIdleConns = 2
config.GroupMe.OSName = "Mautrix-GroupMe bridge" config.GroupMe.OSName = "Go GroupMe bridge"
config.GroupMe.BrowserName = "mx-gm" config.GroupMe.BrowserName = "mx-gm"
config.Bridge.setDefaults() config.Bridge.setDefaults()
} }

View File

@ -6,11 +6,11 @@ fi
# Define functions. # Define functions.
function fixperms { function fixperms {
chown -R $UID:$GID /data /opt/mautrix-groupme chown -R $UID:$GID /data /opt/go-groupme
} }
if [[ ! -f /data/config.yaml ]]; then if [[ ! -f /data/config.yaml ]]; then
cp /opt/mautrix-groupme/example-config.yaml /data/config.yaml cp /opt/go-groupme/example-config.yaml /data/config.yaml
echo "Didn't find a config file." echo "Didn't find a config file."
echo "Copied default config file to /data/config.yaml" echo "Copied default config file to /data/config.yaml"
echo "Modify that config file to your liking." echo "Modify that config file to your liking."
@ -19,7 +19,7 @@ if [[ ! -f /data/config.yaml ]]; then
fi fi
if [[ ! -f /data/registration.yaml ]]; then if [[ ! -f /data/registration.yaml ]]; then
/usr/bin/mautrix-groupme -g -c /data/config.yaml -r /data/registration.yaml /usr/bin/go-groupme -g -c /data/config.yaml -r /data/registration.yaml
echo "Didn't find a registration file." echo "Didn't find a registration file."
echo "Generated one for you." echo "Generated one for you."
echo "Copy that over to synapses app service directory." echo "Copy that over to synapses app service directory."
@ -28,4 +28,4 @@ fi
cd /data cd /data
fixperms fixperms
exec su-exec $UID:$GID /usr/bin/mautrix-groupme exec su-exec $UID:$GID /usr/bin/go-groupme

View File

@ -1,2 +0,0 @@
[*.{yaml,yml}]
indent_size = 2

View File

@ -1,2 +0,0 @@
charts/*
!*.yaml

View File

@ -1,22 +0,0 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

View File

@ -1,14 +0,0 @@
apiVersion: v1
name: mautrix-groupme
version: 0.1.0
appVersion: "0.1.0"
description: A Matrix-GroupMe puppeting bridge.
keywords:
- matrix
- bridge
- groupme
maintainers:
- name: Tulir Asokan
email: tulir@maunium.net
sources:
- https://github.com/tulir/mautrix-whatsapp

View File

@ -1,6 +0,0 @@
dependencies:
- name: postgresql
repository: https://kubernetes-charts.storage.googleapis.com/
version: 6.5.0
digest: sha256:85139e9d4207e49c11c5f84d7920d0135cffd3d427f3f3638d4e51258990de2a
generated: "2019-10-23T22:11:37.005827507+03:00"

View File

@ -1,5 +0,0 @@
dependencies:
- name: postgresql
version: 6.5.0
repository: https://kubernetes-charts.storage.googleapis.com/
condition: postgresql.enabled

View File

@ -1,12 +0,0 @@
Your registration file is below. Save it into a YAML file and give the path to that file to synapse:
id: {{ .Values.appservice.id }}
as_token: {{ .Values.appservice.asToken }}
hs_token: {{ .Values.appservice.hsToken }}
namespaces:
users:
- exclusive: true
regex: "@{{ .Values.bridge.username_template | replace "{{.}}" ".+"}}:{{ .Values.homeserver.domain }}"
url: {{ .Values.appservice.address }}
sender_localpart: {{ .Values.appservice.botUsername }}
rate_limited: false

View File

@ -1,55 +0,0 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "mautrix-groupme.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "mautrix-groupme.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "mautrix-groupme.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Common labels
*/}}
{{- define "mautrix-groupme.labels" -}}
app.kubernetes.io/name: {{ include "mautrix-groupme.name" . }}
helm.sh/chart: {{ include "mautrix-groupme.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{/*
Create the name of the service account to use
*/}}
{{- define "mautrix-groupme.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "mautrix-groupme.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

View File

@ -1,45 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "mautrix-groupme.fullname" . }}
labels:
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
app.kubernetes.io/name: {{ template "mautrix-groupme.name" . }}
data:
config.yaml: |
homeserver:
address: {{ .Values.homeserver.address }}
domain: {{ .Values.homeserver.domain }}
appservice:
address: http://{{ include "mautrix-groupme.fullname" . }}:{{ .Values.service.port }}
hostname: 0.0.0.0
port: {{ .Values.service.port }}
{{- if .Values.postgresql.enabled }}
database:
type: postgres
uri: "postgres://postgres:{{ .Values.postgresql.postgresqlPassword }}@{{ .Release.Name }}-postgresql/{{ .Values.postgresql.postgresqlDatabase }}?sslmode=disable"
{{- else }}
database:
{{- toYaml .Values.appservice.database | nindent 8 }}
{{- end }}
id: {{ .Values.appservice.id }}
bot:
username: {{ .Values.appservice.botUsername }}
displayname: {{ .Values.appservice.botDisplayname }}
avatar: {{ .Values.appservice.botAvatar }}
as_token: {{ .Values.appservice.asToken }}
hs_token: {{ .Values.appservice.hsToken }}
bridge:
{{- toYaml .Values.bridge | nindent 6 }}
logging:
{{- toYaml .Values.logging | nindent 6 }}
registration.yaml: ""

View File

@ -1,69 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "mautrix-groupme.fullname" . }}
labels:
{{- include "mautrix-groupme.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: {{ include "mautrix-groupme.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
{{- if .Values.podAnnotations }}
annotations:
{{- toYaml .Values.podAnnotations | nindent 6 }}
{{- end }}
metadata:
labels:
app.kubernetes.io/name: {{ include "mautrix-groupme.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
serviceAccountName: {{ template "mautrix-groupme.serviceAccountName" . }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
volumeMounts:
- mountPath: /data
name: config-volume
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
# livenessProbe:
# httpGet:
# path: /_matrix/mau/live
# port: http
# initialDelaySeconds: 60
# periodSeconds: 5
# readinessProbe:
# httpGet:
# path: /_matrix/mau/ready
# port: http
# initialDelaySeconds: 60
# periodSeconds: 5
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: config-volume
configMap:
name: {{ template "mautrix-groupme.fullname" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View File

@ -1,16 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "mautrix-groupme.fullname" . }}
labels:
{{ include "mautrix-groupme.labels" . | indent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: {{ include "mautrix-groupme.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}

View File

@ -1,8 +0,0 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "mautrix-groupme.serviceAccountName" . }}
labels:
{{ include "mautrix-groupme.labels" . | indent 4 }}
{{- end -}}

View File

@ -1,137 +0,0 @@
image:
repository: dock.mau.dev/tulir/mautrix-whatsapp
tag: latest
pullPolicy: IfNotPresent
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# Specifies whether a service account should be created
create: true
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name:
service:
type: ClusterIP
port: 29318
resources: {}
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
nodeSelector: {}
tolerations: []
affinity: {}
# Postgres pod configs
postgresql:
enabled: true
postgresqlDatabase: mxwa
postgresqlPassword: SET TO RANDOM STRING
persistence:
size: 2Gi
resources:
requests:
memory: 256Mi
cpu: 100m
# Homeserver details
homeserver:
# The address that this appservice can use to connect to the homeserver.
address: https://example.com
# The domain of the homeserver (for MXIDs, etc).
domain: example.com
# Application service host/registration related details
# Changing these values requires regeneration of the registration.
appservice:
id: whatsapp
botUsername: whatsappbot
# Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty
# to leave display name/avatar as-is.
botDisplayname: WhatsApp bridge bot
botAvatar: mxc://maunium.net/NeXNQarUbrlYBiPCpprYsRqr
# Authentication tokens for AS <-> HS communication.
asToken: SET TO RANDOM STRING
hsToken: SET TO RANDOM STRING
# The keys below can be used to override the configs in the base config:
# https://github.com/tulir/mautrix-whatsapp/blob/master/example-config.yaml
# Note that the "appservice" and "homeserver" sections are above and slightly different than the base.
# Bridge config
bridge:
# Localpart template of MXIDs for WhatsApp users.
# {{.}} is replaced with the phone number of the WhatsApp user.
username_template: whatsapp_{{.}}
# Number of chats to sync for new users.
initial_chat_sync_count: 10
# Number of old messages to fill when creating new portal rooms.
initial_history_fill_count: 20
# Maximum number of chats to sync when recovering from downtime.
# Set to -1 to sync all new chats during downtime.
recovery_chat_sync_limit: -1
# Whether or not to sync history when recovering from downtime.
recovery_history_backfill: true
# Maximum number of seconds since last message in chat to skip
# syncing the chat in any case. This setting will take priority
# over both recovery_chat_sync_limit and initial_chat_sync_count.
# Default is 3 days = 259200 seconds
sync_max_chat_age: 259200
# Whether or not to explicitly set the avatar and room name for private
# chat portal rooms. This can be useful if the previous field works fine,
# but causes room avatar/name bugs.
private_chat_portal_meta: true
# Allow invite permission for user. User can invite any bots to room with whatsapp
# users (private chat and groups)
allow_user_invite: true
# Permissions for using the bridge.
# Permitted values:
# relaybot - Talk through the relaybot (if enabled), no access otherwise
# user - Access to use the bridge to chat with a WhatsApp account.
# admin - User level and some additional administration tools
# Permitted keys:
# * - All Matrix users
# domain - All users on that homeserver
# mxid - Specific user
permissions:
"*": relaybot
"example.com": user
"@admin:example.com": admin
relaybot:
# Whether or not relaybot support is enabled.
enabled: false
# The management room for the bot. This is where all status notifications are posted and
# in this room, you can use `!wa <command>` instead of `!wa relaybot <command>`. Omitting
# the command prefix completely like in user management rooms is not possible.
management: !foo:example.com
# List of users to invite to all created rooms that include the relaybot.
invites: []
# The formats to use when sending messages to WhatsApp via the relaybot.
message_formats:
m.text: "<b>{{ .Sender.Displayname }}</b>: {{ .Message }}"
m.notice: "<b>{{ .Sender.Displayname }}</b>: {{ .Message }}"
m.emote: "* <b>{{ .Sender.Displayname }}</b> {{ .Message }}"
m.file: "<b>{{ .Sender.Displayname }}</b> sent a file"
m.image: "<b>{{ .Sender.Displayname }}</b> sent an image"
m.audio: "<b>{{ .Sender.Displayname }}</b> sent an audio file"
m.video: "<b>{{ .Sender.Displayname }}</b> sent a video"
m.location: "<b>{{ .Sender.Displayname }}</b> sent a location"
logging:
timestamp_format: Jan _2, 2006 15:04:05
print_level: debug

View File

@ -42,7 +42,7 @@ import (
var ( var (
// These are static // These are static
Name = "mautrix-groupme" Name = "go-groupme"
URL = "https://github.com/tulir/mautrix-whatsapp" URL = "https://github.com/tulir/mautrix-whatsapp"
// This is changed when making a release // This is changed when making a release
Version = "0.1.5" Version = "0.1.5"
@ -438,8 +438,8 @@ func (bridge *Bridge) Main() {
func main() { func main() {
flag.SetHelpTitles( flag.SetHelpTitles(
"mautrix-groupme - A Matrix-GroupMe puppeting bridge.", "go-groupme - A Matrix-GroupMe puppeting bridge.",
"mautrix-groupme [-h] [-c <path>] [-r <path>] [-g] [--migrate-db <source type> <source uri>]") "go-groupme [-h] [-c <path>] [-r <path>] [-g] [--migrate-db <source type> <source uri>]")
err := flag.Parse() err := flag.Parse()
if err != nil { if err != nil {
_, _ = fmt.Fprintln(os.Stderr, err) _, _ = fmt.Fprintln(os.Stderr, err)