Update setup_final.sh with user provided working config structure
This commit is contained in:
253
setup_final.sh
253
setup_final.sh
@@ -1,21 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
# FINAL ATTEMPT Script
|
||||
# Uses Mautrix image but switches to Host Networking to bypass Docker NAT issues.
|
||||
# Disables Pings.
|
||||
# Uses bbctl for tokens.
|
||||
# FINAL FINAL ATTEMPT
|
||||
# Uses user's known-good config structure, adapted for Docker + Websocket.
|
||||
|
||||
BRIDGE_SERVICE="telegram"
|
||||
DATA_DIR="data/$BRIDGE_SERVICE"
|
||||
CONFIG_FILE="$DATA_DIR/config.yaml"
|
||||
REG_FILE="$DATA_DIR/registration.yaml"
|
||||
|
||||
# ... (Token extraction logic as before) ...
|
||||
# We'll skip the boilerplate for brevity in this thought process,
|
||||
# but I will write the full script to the file.
|
||||
|
||||
# ... (Token extraction same as before) ...
|
||||
if command -v bbctl &> /dev/null; then
|
||||
echo "Found 'bbctl'. Fetching registration..."
|
||||
BBCTL_OUT=$(bbctl register "sh-$BRIDGE_SERVICE" 2>&1)
|
||||
if [ $? -eq 0 ]; then
|
||||
YAML_CONTENT=$(echo "$BBCTL_OUT" | sed -n '/^id:/,$p')
|
||||
@@ -23,20 +17,18 @@ if command -v bbctl &> /dev/null; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# Parse tokens
|
||||
get_yaml_val() { grep "^$1:" "$REG_FILE" | sed 's/^[^:]*: *//' | tr -d '\r'; }
|
||||
REG_ID=$(get_yaml_val "id")
|
||||
AS_TOKEN=$(get_yaml_val "as_token")
|
||||
HS_TOKEN=$(get_yaml_val "hs_token")
|
||||
BOT_USERNAME=$(get_yaml_val "sender_localpart")
|
||||
|
||||
# Ask API ID/Hash only if not present or empty
|
||||
if [ -z "$API_ID" ]; then
|
||||
read -p "Telegram API ID: " API_ID
|
||||
read -p "Telegram API Hash: " API_HASH
|
||||
fi
|
||||
|
||||
# Config with Ping Disabled and Null Address
|
||||
# USER'S CONFIG (Adapted)
|
||||
cat <<EOF > "$CONFIG_FILE"
|
||||
homeserver:
|
||||
address: https://matrix.beeper.com/_hungryserv/inswe
|
||||
@@ -45,29 +37,230 @@ homeserver:
|
||||
software: hungry
|
||||
http_retry_count: 4
|
||||
async_media: true
|
||||
|
||||
# ADDED FOR DOCKER:
|
||||
websocket: true
|
||||
ping_interval_seconds: -1
|
||||
|
||||
appservice:
|
||||
address: null
|
||||
address: http://localhost:29317
|
||||
hostname: 0.0.0.0
|
||||
port: 29317
|
||||
|
||||
max_body_size: 1
|
||||
|
||||
database: sqlite:////data/bridge.db
|
||||
|
||||
id: $REG_ID
|
||||
bot_username: $BOT_USERNAME
|
||||
as_token: $AS_TOKEN
|
||||
hs_token: $HS_TOKEN
|
||||
database: sqlite:////data/bridge.db
|
||||
|
||||
ephemeral_events: true
|
||||
|
||||
# Beeper usually needs this for WS
|
||||
async_transactions: true
|
||||
|
||||
metrics:
|
||||
enabled: false
|
||||
listen_port: 8000
|
||||
|
||||
manhole:
|
||||
enabled: false
|
||||
|
||||
bridge:
|
||||
username_template: "${BRIDGE_SERVICE}_{userid}"
|
||||
displayname_template: "{displayname} ($BRIDGE_SERVICE)"
|
||||
username_template: ${BRIDGE_SERVICE}_{userid}
|
||||
alias_template: ${BRIDGE_SERVICE}_{groupname}
|
||||
displayname_template: '{displayname}'
|
||||
displayname_preference:
|
||||
- full name
|
||||
- username
|
||||
- phone number
|
||||
displayname_max_length: 100
|
||||
allow_avatar_remove: true
|
||||
allow_contact_info: true
|
||||
max_initial_member_sync: 20
|
||||
max_member_count: 10000
|
||||
sync_channel_members: false
|
||||
skip_deleted_members: true
|
||||
startup_sync: false
|
||||
sync_update_limit: 0
|
||||
sync_create_limit: 10
|
||||
sync_deferred_create_all: true
|
||||
sync_direct_chats: true
|
||||
max_telegram_delete: 10
|
||||
sync_matrix_state: true
|
||||
allow_matrix_login: true
|
||||
public_portals: false
|
||||
sync_with_custom_puppets: false
|
||||
sync_direct_chat_list: false
|
||||
double_puppet_server_map:
|
||||
beeper.com: https://matrix.beeper.com/_hungryserv/inswe
|
||||
double_puppet_allow_discovery: false
|
||||
telegram_link_preview: true
|
||||
invite_link_resolve: false
|
||||
caption_in_message: true
|
||||
image_as_file_size: 10
|
||||
image_as_file_pixels: 5000000
|
||||
parallel_file_transfer: false
|
||||
federate_rooms: false
|
||||
always_custom_emoji_reaction: false
|
||||
animated_sticker:
|
||||
target: webp
|
||||
convert_from_webm: false
|
||||
args:
|
||||
width: 256
|
||||
height: 256
|
||||
fps: 25
|
||||
animated_emoji:
|
||||
target: webp
|
||||
args:
|
||||
width: 64
|
||||
height: 64
|
||||
fps: 25
|
||||
encryption:
|
||||
allow: true
|
||||
default: true
|
||||
appservice: true
|
||||
msc4190: false
|
||||
require: true
|
||||
allow_key_sharing: true
|
||||
delete_keys:
|
||||
delete_outbound_on_ack: true
|
||||
dont_store_outbound: false
|
||||
ratchet_on_decrypt: true
|
||||
delete_fully_used_on_decrypt: true
|
||||
delete_prev_on_new_session: true
|
||||
delete_on_device_delete: true
|
||||
periodically_delete_expired: true
|
||||
delete_outdated_inbound: true
|
||||
verification_levels:
|
||||
receive: cross-signed-tofu
|
||||
send: cross-signed-tofu
|
||||
share: cross-signed-tofu
|
||||
rotation:
|
||||
enable_custom: true
|
||||
milliseconds: 2592000000
|
||||
messages: 10000
|
||||
disable_device_change_key_rotation: true
|
||||
|
||||
private_chat_portal_meta: default
|
||||
disable_reply_fallbacks: true
|
||||
cross_room_replies: false
|
||||
delivery_receipts: false
|
||||
delivery_error_reports: false
|
||||
incoming_bridge_error_reports: true
|
||||
message_status_events: true
|
||||
resend_bridge_info: false
|
||||
mute_bridging: true
|
||||
pinned_tag: m.favourite
|
||||
archive_tag: m.lowpriority
|
||||
tag_only_on_create: true
|
||||
bridge_matrix_leave: false
|
||||
kick_on_logout: false
|
||||
always_read_joined_telegram_notice: true
|
||||
create_group_on_invite: false
|
||||
backfill:
|
||||
enable: true
|
||||
normal_groups: true
|
||||
unread_hours_threshold: 720
|
||||
forward_limits:
|
||||
initial:
|
||||
user: 50
|
||||
normal_group: 100
|
||||
supergroup: 50
|
||||
channel: 50
|
||||
sync:
|
||||
user: 0
|
||||
normal_group: 0
|
||||
supergroup: 0
|
||||
channel: 0
|
||||
forward_timeout: 900
|
||||
incremental:
|
||||
messages_per_batch: 100
|
||||
post_batch_delay: 20
|
||||
max_batches:
|
||||
user: -1
|
||||
normal_group: -1
|
||||
supergroup: 10
|
||||
channel: -1
|
||||
initial_power_level_overrides:
|
||||
user: {}
|
||||
group: {}
|
||||
bot_messages_as_notices: true
|
||||
bridge_notices:
|
||||
default: false
|
||||
exceptions: []
|
||||
relay_user_distinguishers: [🟦, 🟣, 🟩, ⭕️, 🔶, ⬛️, 🔵, 🟢]
|
||||
message_formats:
|
||||
m.text: '$distinguisher <b>$sender_displayname</b>: $message'
|
||||
m.notice: '$distinguisher <b>$sender_displayname</b>: $message'
|
||||
m.emote: '* $distinguisher <b>$sender_displayname</b> $message'
|
||||
m.file: '$distinguisher <b>$sender_displayname</b> sent a file: $message'
|
||||
m.image: '$distinguisher <b>$sender_displayname</b> sent an image: $message'
|
||||
m.audio: '$distinguisher <b>$sender_displayname</b> sent an audio file: $message'
|
||||
m.video: '$distinguisher <b>$sender_displayname</b> sent a video: $message'
|
||||
m.location: '$distinguisher <b>$sender_displayname</b> sent a location: $message'
|
||||
emote_format: '* $mention $formatted_body'
|
||||
state_event_formats:
|
||||
join: $distinguisher <b>$displayname</b> joined the room.
|
||||
leave: $distinguisher <b>$displayname</b> left the room.
|
||||
name_change: $distinguisher <b>$prev_displayname</b> changed their name to $distinguisher <b>$displayname</b>
|
||||
filter:
|
||||
mode: blacklist
|
||||
list: []
|
||||
users: true
|
||||
command_prefix: '!tg'
|
||||
management_room_text:
|
||||
welcome: Hello, I'm a Telegram bridge bot.
|
||||
welcome_connected: Use `help` for help.
|
||||
welcome_unconnected: Use `help` for help or `login` to log in.
|
||||
additional_help: ''
|
||||
management_room_multiple_messages: false
|
||||
permissions:
|
||||
"*": relay
|
||||
"beeper.local": user
|
||||
"beeper.com": user
|
||||
"@inswe:beeper.com": admin
|
||||
relay:
|
||||
enabled: true
|
||||
admin_only: false
|
||||
'beeper.local': user
|
||||
'beeper.com': user
|
||||
'@inswe:beeper.com': admin
|
||||
relaybot:
|
||||
private_chat:
|
||||
invite: []
|
||||
state_changes: true
|
||||
message: This is a Matrix bridge relaybot and does not support direct chats
|
||||
group_chat_invite: []
|
||||
ignore_unbridged_group_chat: true
|
||||
authless_portals: true
|
||||
whitelist_group_admins: true
|
||||
ignore_own_incoming_events: true
|
||||
whitelist: []
|
||||
|
||||
telegram:
|
||||
api_id: $API_ID
|
||||
api_hash: $API_HASH
|
||||
bot_token: disabled
|
||||
catch_up: true
|
||||
sequential_updates: true
|
||||
exit_on_update_error: true
|
||||
force_refresh_interval_seconds: 0
|
||||
connection:
|
||||
timeout: 120
|
||||
retries: 5
|
||||
retry_delay: 1
|
||||
flood_sleep_threshold: 60
|
||||
request_retries: 5
|
||||
use_ipv6: false
|
||||
device_info:
|
||||
device_model: Beeper (self-hosted)
|
||||
system_version: auto
|
||||
app_version: auto
|
||||
lang_code: en
|
||||
system_lang_code: en
|
||||
server:
|
||||
enabled: false
|
||||
dc: 2
|
||||
ip: 149.154.167.40
|
||||
port: 80
|
||||
proxy:
|
||||
type: disabled
|
||||
|
||||
logging:
|
||||
version: 1
|
||||
@@ -83,17 +276,8 @@ logging:
|
||||
root:
|
||||
level: INFO
|
||||
handlers: [console]
|
||||
|
||||
telegram:
|
||||
api_id: $API_ID
|
||||
api_hash: $API_HASH
|
||||
device_info:
|
||||
device_model: "Beeper Bridge"
|
||||
system_version: "Docker"
|
||||
app_version: "0.1"
|
||||
EOF
|
||||
|
||||
# Docker Compose with Host Network
|
||||
cat <<EOF > docker-compose.yml
|
||||
services:
|
||||
telegram:
|
||||
@@ -104,6 +288,7 @@ services:
|
||||
volumes:
|
||||
- ./data/telegram:/data
|
||||
environment:
|
||||
# Explicitly force websocket via env var just in case
|
||||
- MAUTRIX_TELEGRAM_HOMESERVER_WEBSOCKET=true
|
||||
logging:
|
||||
driver: json-file
|
||||
@@ -112,6 +297,6 @@ services:
|
||||
max-file: "3"
|
||||
EOF
|
||||
|
||||
echo "Starting with Host Network..."
|
||||
echo "Starting FINAL ATTEMPT..."
|
||||
docker compose up -d --force-recreate telegram
|
||||
docker compose logs -f telegram
|
||||
docker compose logs -f telegram
|
||||
Reference in New Issue
Block a user