matrix使用
# https://hub.docker.com/r/matrixdotorg/synapse/#!
# https://github.com/matrix-org/synapse
# 可能有的常量不会生效, 以生成的/homeserver.yaml配置文件端口为准
# 创建配置文件
docker run -it --rm \
-e SYNAPSE_SERVER_NAME=matrix.leng2011.icu \
-e SYNAPSE_REPORT_STATS=yes \
-e SYNAPSE_HTTP_PORT=8008 \
-v /home/jcleng/matrix:/data \
-p 8008:8008 \
-u $UID \
matrixdotorg/synapse:latest generate
# 运行
docker run -itd \
-e SYNAPSE_SERVER_NAME=matrix.leng2011.icu \
-v /home/jcleng/matrix:/data \
--network=host \
-u $UID \
--name=matrix \
matrixdotorg/synapse:latest
# 修改注册权限
# 配置文件
https://matrix-org.github.io/synapse/latest/usage/configuration/config_documentation.html
vi /home/jcleng/matrix/homeserver.yaml
# 开放用户注册
enable_registration: true
enable_registration_without_verification: true
docker restart matrix
# docker exec -u root -it matrix bash
# useradd jcleng
# docker exec -it matrix bash
# 代理到80端口和https
# matrix caddy
matrix.leng2011.icu:80 {
reverse_proxy * {
to http://127.0.0.1:8008
}
}
matrix.leng2011.icu:443 {
reverse_proxy * {
to http://127.0.0.1:8008
}
tls /home/jcleng/matrix_cert/matrix.leng2011.icu_nginx/matrix.leng2011.icu_bundle.crt /home/jcleng/matrix_cert/matrix.leng2011.icu_nginx/matrix.leng2011.icu.key
}
# 客户端
https://matrix.leng2011.icu:8008/.well-known/matrix/client
# web 客户端 https://app.element.io
https://github.com/vector-im/element-web/releases/download/v1.11.40-rc.1/element-v1.11.40-rc.1.tar.gz
# 命令行客户端
https://github.com/tulir/gomuks/releases
分享页面的客户端列表: https://matrix.to/#/#hd2:matrix.leng2011.icu
https://fluffychat.im/
# 客户端配置 https://github.com/vector-im/element-web/blob/master/docs/config.md
flatpak install flathub im.riot.Riot -y
# 编辑配置文件 https://github.com/vector-im/element-web/blob/develop/docs/config.md
/home/jcleng/.var/app/im.riot.Riot/config/Element/config.json
# windows在%AppData%/Element/config.json
# 配置自己的服务器地址如下
{
"default_server_config": {
"m.homeserver": {
"base_url": "https://matrix.leng2011.icu"
}
}
}
homeserver.yaml原文
# Configuration file for Synapse.
#
# This is a YAML file: see [1] for a quick introduction. Note in particular
# that *indentation is important*: all the elements of a list or dictionary
# should have the same indentation.
#
# [1] https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html
#
# For more information on how to configure Synapse, including a complete accounting of
# each option, go to docs/usage/configuration/config_documentation.md or
# https://matrix-org.github.io/synapse/latest/usage/configuration/config_documentation.html
server_name: "matrix.leng2011.icu"
pid_file: /data/homeserver.pid
listeners:
- port: 8008
tls: false
type: http
x_forwarded: true
resources:
- names: [client, federation]
compress: false
database:
name: sqlite3
args:
database: /data/homeserver.db
log_config: "/data/matrix.leng2011.icu.log.config"
media_store_path: /data/media_store
registration_shared_secret: "-vfpToQ7r=HIjpX=ojZ93t.xbpH_^+ruO~,LiSl9AB_Tt3E4OI"
report_stats: true
macaroon_secret_key: "Zu0;~zS*h;I;SWGtWKmckcybzJ0a7f-th;_B6-AH@2z8yR-^_4"
form_secret: "9SW0Crolsrvw,Ip=L84AwQw5I1lSaeIs:AIJCII=^j5o2=.mlb"
signing_key_path: "/data/matrix.leng2011.icu.signing.key"
# 信任的密钥下载地址,跨域名服务
trusted_key_servers:
- server_name: "matrix.leng2011.icu"
# 指定到https
serve_server_wellknown: true
# 允许访问房间
allow_public_rooms_over_federation: true
allow_public_rooms_without_auth: true
# 开放用户注册
enable_registration: true
enable_registration_without_verification: true
# vim:ft=yaml
# 默认分享是使用的matrix.to的页面
cd /home/jcleng/to
wget https://github.com/matrix-org/matrix.to/releases/download/1.2.16/matrixto-1.2.16.tar.gz
tar xvf matrixto-1.2.16.tar.gz
# matrix to
to.leng2011.icu:80 {
root * /home/jcleng/to
file_server
}
# http://to.leng2011.icu/#/@jcleng:matrix.leng2011.icu?client=im.fluffychat
matrix-qq
# 创建配置文件config.yaml
docker run --rm -v `pwd`/matrix-qq:/data:z lxduo/matrix-qq:latest
# 编辑对应的注册文件,主要是[替换所有域名]和[数据库]以及[监听地址为外网地址]
# sqlite3的话直接配置db文件地址即可
# uri: /data/qq.db
# 编辑完成之后再生成注册文件registration.yaml[修改url为外网地址和权限]
docker run --rm -v `pwd`/matrix-qq:/data:z lxduo/matrix-qq:latest
# 复制注册文件到matrix目录
cp matrix-qq/registration.yaml matrix/qq-registration.yaml
# 权限
chown 991:991 matrix/qq-registration.yaml
# 配置matrix/homeserver.yaml
app_service_config_files:
- /data/qq-registration.yaml
# 重启matrix服务
docker restart matrix
# 运行matrixqq服务, 测试成功之后加上-itd后台运行即可
docker run --rm \
-v `pwd`/matrix-qq:/data:z \
--network=host \
--name=matrixqq \
lxduo/matrix-qq:latest
新建和
@qqbot:matrix.leng2011.icu的聊天,注意不要端对端加密
# 机器人默认是离线的,不影响使用
# 输入 help 查看使用帮助
qq-registration.yaml原文
id: qq
url: http://matrix.leng2011.icu:17777
as_token: Ma88gENxJ58g0IL5eOlYgbdEDFCNVkEerX3wboWaQ9yOzbhjj0KMscOS0w2FPwlN
hs_token: lLDuLbjz4StzJ9N0hHqrVwOvRFVGT4O210xYD1rt0Ug3CAiVH8zcBdvPDvYsGHgu
sender_localpart: VmMOXxQlyw80tsrSy6r2tbw3d78IJrbc
rate_limited: false
namespaces:
users:
- regex: ^@qqbot:matrix\.leng2011\.icu$
exclusive: true
- regex: ^@_qq_.*:matrix\.leng2011\.icu$
exclusive: true
de.sorunome.msc2409.push_ephemeral: true
push_ephemeral: true
原文
# Homeserver details.
homeserver:
# The address that this appservice can use to connect to the homeserver.
address: https://matrix.leng2011.icu
# The domain of the homeserver (for MXIDs, etc).
domain: matrix.leng2011.icu
# What software is the homeserver running?
# Standard Matrix homeservers like Synapse, Dendrite and Conduit should just use "standard" here.
software: standard
# The URL to push real-time bridge status to.
# If set, the bridge will make POST requests to this URL whenever a user's connection state changes.
# The bridge will use the appservice as_token to authorize requests.
status_endpoint: null
# Endpoint for reporting per-message status.
message_send_checkpoint_endpoint: null
# Does the homeserver support https://github.com/matrix-org/matrix-spec-proposals/pull/2246?
async_media: false
# 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://matrix.leng2011.icu:17777
# The hostname and port where this appservice should listen.
hostname: 0.0.0.0
port: 17777
# Database config.
database:
# The database type. "sqlite3" and "postgres" are supported.
type: sqlite3-fk-wal
# The database URI.
# SQLite: File name is enough. https://github.com/mattn/go-sqlite3#connection-string
# Postgres: Connection string. For example, postgres://user:password@host/database?sslmode=disable
# To connect via Unix socket, use something like postgres:///dbname?host=/var/run/postgresql
uri: /data/qq.db
# Maximum number of connections. Mostly relevant for Postgres.
max_open_conns: 20
max_idle_conns: 2
# Maximum connection idle time and lifetime before they're closed. Disabled if null.
# Parsed with https://pkg.go.dev/time#ParseDuration
max_conn_idle_time: null
max_conn_lifetime: null
# The unique ID of this appservice.
id: qq
# Appservice bot details.
bot:
# Username of the appservice bot.
username: qqbot
# Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty
# to leave display name/avatar as-is.
displayname: QQ bridge bot
avatar: mxc://matrix.org/nKrjlWVnjIGQRJicsBqDFLnc
# Whether or not to receive ephemeral events via appservice transactions.
# Requires MSC2409 support (i.e. Synapse 1.22+).
# You should disable bridge -> sync_with_custom_puppets when this is enabled.
ephemeral_events: true
# Authentication tokens for AS <-> HS communication. Autogenerated; do not modify.
as_token: "Ma88gENxJ58g0IL5eOlYgbdEDFCNVkEerX3wboWaQ9yOzbhjj0KMscOS0w2FPwlN"
hs_token: "lLDuLbjz4StzJ9N0hHqrVwOvRFVGT4O210xYD1rt0Ug3CAiVH8zcBdvPDvYsGHgu"
# QQ config
qq:
# QQ client protocol (1: AndroidPhone, 2: AndroidWatch, 3: MacOS, 4: QiDian, 5: IPad, 6: AndroidPad)
protocol: 5
# Bridge config
bridge:
# Localpart template of MXIDs for QQ users.
username_template: _qq_{{.}}
# Displayname template for QQ users.
displayname_template: "{{if .Name}}{{.Name}}{{else}}{{.Uin}}{{end}} (QQ)"
# Should the bridge create a space for each logged-in user and add bridged rooms to it?
# Users who logged in before turning this on should run `!wa sync space` to create and fill the space for the first time.
personal_filtering_spaces: false
# Whether the bridge should send the message status as a custom com.beeper.message_send_status event.
message_status_events: false
# Whether the bridge should send error notices via m.notice events when a message fails to bridge.
message_error_notices: true
portal_message_buffer: 128
# Enable redaction
allow_redaction: false
# Should puppet avatars be fetched from the server even if an avatar is already set?
user_avatar_sync: true
# Should the bridge sync with double puppeting to receive EDUs that aren't normally sent to appservices.
sync_with_custom_puppets: false
# Should the bridge update the m.direct account data event when double puppeting is enabled.
# Note that updating the m.direct event is not atomic (except with mautrix-asmux)
# and is therefore prone to race conditions.
sync_direct_chat_list: false
# When double puppeting is enabled, users can use `!wa toggle` to change whether
# presence is bridged. These settings set the default values.
# Existing users won't be affected when these are changed.
default_bridge_presence: false
# Send the presence as "available" to QQ when users start typing on a portal.
# This works as a workaround for homeservers that do not support presence, and allows
# users to see when the qq user on the other side is typing during a conversation.
send_presence_on_typing: false
# Servers to always allow double puppeting from
double_puppet_server_map:
matrix.leng2011.icu: https://matrix.leng2011.icu
# Allow using double puppeting from any server with a valid client .well-known file.
double_puppet_allow_discovery: false
# Shared secrets for https://github.com/devture/matrix-synapse-shared-secret-auth
#
# If set, double puppeting will be enabled automatically for local users
# instead of users having to find an access token and run `login-matrix`
# manually.
login_shared_secret_map:
matrix.leng2011.icu: foobar
# Should the bridge explicitly set the avatar and room name for private chat portal rooms?
private_chat_portal_meta: false
# Should group members be synced in parallel? This makes member sync faster
parallel_member_sync: false
# Set this to true to tell the bridge to re-send m.bridge events to all rooms on the next run.
# This field will automatically be changed back to false after it, except if the config file is not writable.
resend_bridge_info: false
# When using double puppeting, should muted chats be muted in Matrix?
mute_bridging: false
# Allow invite permission for user. User can invite any bots to room with qq
# users (private chat and groups)
allow_user_invite: false
# Whether or not created rooms should have federation enabled.
# If false, created portal rooms will never be federated.
federate_rooms: true
# Should the bridge never send alerts to the bridge management room?
# These are mostly things like the user being logged out.
disable_bridge_alerts: false
# Maximum time for handling Matrix events. Duration strings formatted for https://pkg.go.dev/time#ParseDuration
# Null means there's no enforced timeout.
message_handling_timeout:
# Send an error message after this timeout, but keep waiting for the response until the deadline.
# This is counted from the origin_server_ts, so the warning time is consistent regardless of the source of delay.
# If the message is older than this when it reaches the bridge, the message won't be handled at all.
error_after: null
# Drop messages after this timeout. They may still go through if the message got sent to the servers.
# This is counted from the time the bridge starts handling the message.
deadline: 120s
# The prefix for commands. Only required in non-management rooms.
command_prefix: "!qq"
# Messages sent upon joining a management room.
# Markdown is supported. The defaults are listed below.
management_room_text:
# Sent when joining a room.
welcome: "Hello, I'm a QQ bridge bot."
# Sent when joining a management room and the user is already logged in.
welcome_connected: "Use `help` for help."
# Sent when joining a management room and the user is not logged in.
welcome_unconnected: "Use `help` for help or `login` to log in."
# Optional extra text sent when joining a management room.
additional_help: ""
# End-to-bridge encryption support options.
#
# See https://docs.mau.fi/bridges/general/end-to-bridge-encryption.html for more info.
encryption:
# Allow encryption, work in group chat rooms with e2ee enabled
allow: false
# Default to encryption, force-enable encryption in all portals the bridge creates
# This will cause the bridge bot to be in private chats for the encryption to work properly.
# It is recommended to also set private_chat_portal_meta to true when using this.
default: false
# Whether to use MSC2409/MSC3202 instead of /sync long polling for receiving encryption-related data.
appservice: false
# Require encryption, drop any unencrypted messages.
require: false
# Enable key sharing? If enabled, key requests for rooms where users are in will be fulfilled.
# You must use a client that supports requesting keys from other users to use this feature.
allow_key_sharing: false
# What level of device verification should be required from users?
#
# Valid levels:
# unverified - Send keys to all device in the room.
# cross-signed-untrusted - Require valid cross-signing, but trust all cross-signing keys.
# cross-signed-tofu - Require valid cross-signing, trust cross-signing keys on first use (and reject changes).
# cross-signed-verified - Require valid cross-signing, plus a valid user signature from the bridge bot.
# Note that creating user signatures from the bridge bot is not currently possible.
# verified - Require manual per-device verification
# (currently only possible by modifying the `trust` column in the `crypto_device` database table).
verification_levels:
# Minimum level for which the bridge should send keys to when bridging messages from QQ to Matrix.
receive: unverified
# Minimum level that the bridge should accept for incoming Matrix messages.
send: unverified
# Minimum level that the bridge should require for accepting key requests.
share: cross-signed-tofu
# Options for Megolm room key rotation. These options allow you to
# configure the m.room.encryption event content. See:
# https://spec.matrix.org/v1.3/client-server-api/#mroomencryption for
# more information about that event.
rotation:
# Enable custom Megolm room key rotation settings. Note that these
# settings will only apply to rooms created after this option is
# set.
enable_custom: false
# The maximum number of milliseconds a session should be used
# before changing it. The Matrix spec recommends 604800000 (a week)
# as the default.
milliseconds: 604800000
# The maximum number of messages that should be sent with a given a
# session before changing it. The Matrix spec recommends 100 as the
# default.
messages: 100
# Permissions for using the bridge.
# Permitted values:
# user - Access to use the bridge to chat with a QQ account.
# admin - User level and some additional administration tools
# Permitted keys:
# * - All Matrix users
# domain - All users on that homeserver
# mxid - Specific user
permissions:
"matrix.leng2011.icu": user
"@admin:matrix.leng2011.icu": admin
# Logging config.
logging:
# The directory for log files. Will be created if not found.
directory: ./logs
# Available variables: .Date for the file date and .Index for different log files on the same day.
# Set this to null to disable logging to file.
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: 0o600
# Timestamp format for log entries in the Go time format.
timestamp_format: "Jan _2, 2006 15:04:05"
# Minimum severity for log messages printed to stdout/stderr. This doesn't affect the log file.
# Options: debug, info, warn, error, fatal
print_level: debug
其他机器人t2bot.io 需要不是点对点的群内使用