initial commit

This commit is contained in:
Sebastian Hugentobler 2018-11-27 13:12:34 +01:00
commit cc210a0da0
9 changed files with 171 additions and 0 deletions

14
.drone.yml Normal file
View File

@ -0,0 +1,14 @@
pipeline:
docker:
image: plugins/docker
repo: thallian/matrix-appservice-whatsapp
autotag: true
secrets: [ docker_username, docker_password ]
tags:
- ${DRONE_COMMIT_SHA}
- ${DRONE_COMMIT_BRANCH}
- latest
notify:
image: plugins/matrix
secrets: [ matrix_username, matrix_password, matrix_homeserver, matrix_roomid ]

9
.editorconfig Normal file
View File

@ -0,0 +1,9 @@
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4

3
.gitignore vendored Executable file
View File

@ -0,0 +1,3 @@
*~
.DS_Store
*.swp

27
Dockerfile Normal file
View File

@ -0,0 +1,27 @@
FROM golang:alpine as builder
RUN apk --no-cache add \
git \
gcc \
musl-dev
RUN go get maunium.net/go/mautrix-whatsapp
FROM thallian/confd-env:latest
RUN addgroup -g 2222 matrix-bridge
RUN adduser -h /var/lib/matrix-bridge -u 2222 -D -G matrix-bridge matrix-bridge
COPY --from=builder /go/bin/mautrix-whatsapp /bin/mautrix-whatsapp
WORKDIR /var/lib/matrix-bridge
RUN mkdir /var/lib/matrix-bridge/data
ADD /rootfs /
RUN chown -R matrix-bridge:matrix-bridge /var/lib/matrix-bridge
ENV HOME /var/lib/matrix-bridge
EXPOSE 9005

23
README.md Normal file
View File

@ -0,0 +1,23 @@
[whatsapp bridge](https://github.com/tulir/mautrix-whatsapp) for the [matrix](http://matrix.org/) network.
# Volumes
- `/var/lib/matrix-bridge/data`
# Environment Variables
## SERVER_DOMAIN
Domain of the synapse server.
## SERVER_URL
Full url to the synapse server.
## AS_TOKEN
Appservice token (from the generated registration)
## HS_TOKEN
Homeserver token (from the generated registration)
## ADMIN_USER
Matrix id of the admin user.
# Ports
- 8080

View File

@ -0,0 +1,6 @@
[template]
src = "config.yaml.tmpl"
dest = "/var/lib/matrix-bridge/config.yaml"
uid = 2222
gid = 2222
mode = "0640"

View File

@ -0,0 +1,84 @@
# Homeserver details.
homeserver:
# The address that this appservice can use to connect to the homeserver.
address: "{{ getenv "SERVER_URL" }}"
# The domain of the homeserver (for MXIDs, etc).
domain: "{{ getenv "SERVER_DOMAIN" }}"
# Application service host/registration related details.
# Changing these values requires regeneration of the registration.
appservice:
# The address that the homeserver can use to connect to this appservice.
address: http://{{getenv "HOSTNAME"}}:8080
# The hostname and port where this appservice should listen.
hostname: 0.0.0.0
port: 8080
# Database config.
database:
# The database type. Only "sqlite3" is supported.
type: sqlite3
# The database URI. Usually file name. https://github.com/mattn/go-sqlite3#connection-string
uri: /var/lib/matrix-bridge/data/mautrix-whatsapp.db
# Path to the Matrix room state store.
state_store_path: /var/lib/matrix-bridge/data/mx-state.json
# The unique ID of this appservice.
id: whatsapp
# Appservice bot details.
bot:
# Username of the appservice bot.
username: _whatsapp_bot
# Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty
# to leave display name/avatar as-is.
displayname: WhatsApp Bridge Bot
avatar: mxc://maunium.net/NeXNQarUbrlYBiPCpprYsRqr
# Authentication tokens for AS <-> HS communication. Autogenerated; do not modify.
as_token: ""
hs_token: ""
# Bridge config. Currently unused.
bridge:
# Localpart template of MXIDs for WhatsApp users.
# {{.}} is replaced with the phone number of the WhatsApp user.
username_template: whatsapp_{{.}}
# Displayname template for WhatsApp users.
# {{.Notify}} - nickname set by the WhatsApp user
# {{.Jid}} - phone number (international format)
# The following variables are also available, but will cause problems on multi-user instances:
# {{.Name}} - display name from contact list
# {{.Short}} - short display name from contact list
displayname_template: "{{if .Notify}}{{.Notify}}{{else}}{{.Jid}}{{end}} (WA)"
# The prefix for commands. Only required in non-management rooms.
command_prefix: "!wa"
# Permissions for using the bridge.
# Permitted values:
# 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:
"{{ getenv "SERVER_DOMAIN" }}": user
"{{ getenv "ADMIN_USER" }}": admin
# Logging config.
logging:
# The directory for log files. Will be created if not found.
directory: /var/lib/matrix-bridge/logs
# Available variables: .Date for the file date and .Index for different log files on the same day.
file_name_format: "{{.Date}}-{{.Index}}.log"
# Date format for file names in the Go time format: https://golang.org/pkg/time/#pkg-constants
file_date_format: 2006-01-02
# Log file permissions.
file_mode: 0600
# Timestamp format for log entries in the Go time format.
timestamp_format: Jan _2, 2006 15:04:05
# Minimum severity for log messages.
# Options: debug, info, warn, error, fatal
print_level: info

View File

@ -0,0 +1,2 @@
/var/lib/matrix-bridge/data/ true matrix-bridge 0640 0750

View File

@ -0,0 +1,3 @@
#!/usr/bin/with-contenv sh
s6-setuidgid matrix-bridge mautrix-whatsapp -c /var/lib/matrix-bridge/config.yaml