forked from narayana.im/telegabber
Compare commits
3 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1fdf6208c | ||
|
|
ffa8c72379 | ||
|
|
ba8f4c08cf |
10 changed files with 188 additions and 14 deletions
12
Dockerfile
12
Dockerfile
|
|
@ -1,7 +1,7 @@
|
|||
FROM golang:1.19-bookworm AS base
|
||||
|
||||
RUN apt-get update
|
||||
run apt-get install -y libssl-dev cmake build-essential gperf libz-dev make git
|
||||
RUN apt-get install -y libssl-dev cmake build-essential gperf libz-dev make git
|
||||
|
||||
FROM base AS tdlib
|
||||
|
||||
|
|
@ -28,9 +28,13 @@ ARG MAKEOPTS
|
|||
WORKDIR /src
|
||||
RUN make ${MAKEOPTS}
|
||||
|
||||
FROM scratch AS telegabber
|
||||
# Build to image
|
||||
FROM debian:bookworm AS telegabber
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y libssl-dev gperf
|
||||
COPY --from=build /src/release/telegabber /usr/local/bin/
|
||||
RUN ls -l /usr/local/bin/
|
||||
ENTRYPOINT ["/usr/local/bin/telegabber"]
|
||||
CMD ["/usr/local/bin/telegabber", "--help"]
|
||||
|
||||
|
||||
FROM scratch AS binaries
|
||||
COPY --from=telegabber /usr/local/bin/telegabber /
|
||||
|
|
|
|||
4
Makefile
4
Makefile
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
COMMIT := $(shell git rev-parse --short HEAD)
|
||||
TD_COMMIT := "5bbfc1cf5dab94f82e02f3430ded7241d4653551"
|
||||
VERSION := "v1.9.5"
|
||||
VERSION := "v1.9.6"
|
||||
MAKEOPTS := "-j4"
|
||||
|
||||
all:
|
||||
|
|
@ -16,7 +16,7 @@ lint:
|
|||
$(GOPATH)/bin/golint ./...
|
||||
|
||||
build_indocker:
|
||||
docker build --build-arg "TD_COMMIT=${TD_COMMIT}" --build-arg "VERSION=${VERSION}" --build-arg "MAKEOPTS=${MAKEOPTS}" --output=release --target binaries .
|
||||
docker build --build-arg "TD_COMMIT=${TD_COMMIT}" --build-arg "VERSION=${VERSION}" --build-arg "MAKEOPTS=${MAKEOPTS}" -t telegabber:latest . ; docker build -f lighttpd . -t lighttpd:telegabber
|
||||
|
||||
build_indocker_staging:
|
||||
DOCKER_BUILDKIT=1 docker build --build-arg "TD_COMMIT=${TD_COMMIT}" --build-arg "MAKEOPTS=${MAKEOPTS}" --network host --output=release --target binaries -f staging.Dockerfile .
|
||||
|
|
|
|||
24
docker/config/config.yml
Executable file
24
docker/config/config.yml
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
:telegram:
|
||||
:loglevel: :warn
|
||||
:content:
|
||||
:path: '/data' # webserver workdir
|
||||
:link: 'https://uploads.porno4free.ru/content' # webserver public address
|
||||
:upload: 'https://uploads.porno4free.ru' # xmpp http upload address
|
||||
:tdlib_verbosity: 1
|
||||
:tdlib:
|
||||
:datadir: '/etc/telegabber/db/sessions/'
|
||||
:client:
|
||||
:api_id: '11471191'
|
||||
:api_hash: 'f7667171b1a8f1e2f8f2702a8a09e9d2'
|
||||
:device_model: 'telegabber'
|
||||
:application_version: '2.0'
|
||||
:use_chat_info_database: false
|
||||
:use_secret_chats: true
|
||||
|
||||
:xmpp:
|
||||
:loglevel: :warn
|
||||
:jid: 'btg.porno4free.ru'
|
||||
:host: 'prosody'
|
||||
:port: 5347
|
||||
:password: 'YCvxuyXYQwpW3Y7IARN'
|
||||
:db: '/etc/telegabber/db/dbsessions.dat'
|
||||
104
docker/config/config_schema.json
Executable file
104
docker/config/config_schema.json
Executable file
|
|
@ -0,0 +1,104 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"type": "object",
|
||||
"required": [":telegram", ":xmpp"],
|
||||
"properties": {
|
||||
":telegram": {
|
||||
"type": "object",
|
||||
"required": [":loglevel", ":content", ":tdlib"],
|
||||
"properties": {
|
||||
":loglevel": {
|
||||
"$ref": "#/definitions/non-empty-string"
|
||||
},
|
||||
":content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
":path": {
|
||||
"type": "string"
|
||||
},
|
||||
":link": {
|
||||
"type": "string"
|
||||
},
|
||||
":upload": {
|
||||
"type": "string"
|
||||
},
|
||||
":user": {
|
||||
"type": "string"
|
||||
},
|
||||
":quota": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
":tdlib_verbosity": {
|
||||
"type": "integer"
|
||||
},
|
||||
":tdlib": {
|
||||
"required": [":client"],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
":datadir": {
|
||||
"type": "string"
|
||||
},
|
||||
":client": {
|
||||
"type": "object",
|
||||
"required": [":api_id", ":api_hash"],
|
||||
"properties": {
|
||||
":api_id": {
|
||||
"type": "string",
|
||||
"pattern": "^[0-9]+$"
|
||||
},
|
||||
":api_hash": {
|
||||
"$ref": "#/definitions/non-empty-string"
|
||||
},
|
||||
":device_model": {
|
||||
"type": "string"
|
||||
},
|
||||
":application_version": {
|
||||
"type": "string"
|
||||
},
|
||||
":use_chat_info_database": {
|
||||
"type": "boolean"
|
||||
},
|
||||
":use_secret_chats": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
":xmpp": {
|
||||
"type": "object",
|
||||
"required": [":loglevel", ":jid", ":host", ":port", ":password", ":db"],
|
||||
"properties": {
|
||||
":loglevel": {
|
||||
"$ref": "#/definitions/non-empty-string"
|
||||
},
|
||||
":jid": {
|
||||
"$ref": "#/definitions/non-empty-string"
|
||||
},
|
||||
":host": {
|
||||
"$ref": "#/definitions/non-empty-string"
|
||||
},
|
||||
":port": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
":password": {
|
||||
"$ref": "#/definitions/non-empty-string"
|
||||
},
|
||||
":db": {
|
||||
"$ref": "#/definitions/non-empty-string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"non-empty-string": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
docker/data/test.jpg
Executable file
BIN
docker/data/test.jpg
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
22
docker/docker-compose.yml
Executable file
22
docker/docker-compose.yml
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
services:
|
||||
telegabber:
|
||||
image: telegabber:latest
|
||||
container_name: telegabber
|
||||
volumes:
|
||||
- ./config:/etc/telegabber/:ro
|
||||
- ./config/db:etc/telegabber/db:rw
|
||||
- ./data:/data/:rw
|
||||
restart: unless-stopped
|
||||
entrypoint: ["/usr/local/bin/telegabber"]
|
||||
command: ["-schema", "/etc/telegabber/config_schema.json", "--config", "/etc/telegabber/config.yml"]
|
||||
|
||||
lighttpd:
|
||||
image: lighttpd:telegabber
|
||||
container_name: lighttpd-telegabber
|
||||
volumes:
|
||||
- ./data:/data:rw
|
||||
- ./config:/etc/telegabber:ro
|
||||
ports:
|
||||
- "80:80"
|
||||
restart: unless-stopped
|
||||
|
||||
4
lighttpd
Normal file
4
lighttpd
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
FROM jitesoft/lighttpd
|
||||
COPY lighttpd.conf /etc/lighttpd/lighttpd.conf
|
||||
EXPOSE 80
|
||||
CMD ["lighttpd", "-D", "-f", "/etc/lighttpd/lighttpd.conf"]
|
||||
3
lighttpd.conf
Normal file
3
lighttpd.conf
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
server.document-root = "/data"
|
||||
server.port = 80
|
||||
index-file.names = ("index.html")
|
||||
|
|
@ -16,7 +16,7 @@ import (
|
|||
goxmpp "gosrc.io/xmpp"
|
||||
)
|
||||
|
||||
var version string = "1.9.5"
|
||||
var version string = "1.9.6"
|
||||
var commit string
|
||||
|
||||
var sm *goxmpp.StreamManager
|
||||
|
|
|
|||
|
|
@ -582,7 +582,7 @@ func (c *Client) PermastoreFile(file *client.File, clone bool) (string, string)
|
|||
}
|
||||
} else {
|
||||
// move
|
||||
err = os.Rename(src, dest)
|
||||
err = os.copyFile(src, dest)
|
||||
if err != nil {
|
||||
linkErr := err.(*os.LinkError)
|
||||
if linkErr.Err.Error() == "file exists" {
|
||||
|
|
@ -1058,13 +1058,19 @@ func (c *Client) ProcessIncomingMessage(chatId int64, message *client.Message) {
|
|||
fileName, link := c.formatFile(file, false)
|
||||
|
||||
oob = link
|
||||
if c.Session.OOBMode && oob != "" {
|
||||
typ := message.Content.MessageContentType()
|
||||
if typ != client.TypeMessageSticker {
|
||||
auxText = text
|
||||
oobSwap := c.Session.OOBMode && oob != ""
|
||||
|
||||
var ignorePrefix bool
|
||||
if oobSwap {
|
||||
if text == "" || message.Content.MessageContentType() == client.TypeMessageSticker {
|
||||
isPM, err := c.IsPM(chatId)
|
||||
if err == nil {
|
||||
ignorePrefix = isPM && c.isCarbonsEnabled()
|
||||
}
|
||||
}
|
||||
text = oob
|
||||
} else if !c.Session.RawMessages {
|
||||
}
|
||||
|
||||
if !c.Session.RawMessages && !ignorePrefix {
|
||||
var newText strings.Builder
|
||||
|
||||
prefix, prefixReply := c.messageToPrefix(message, previewName, fileName, false)
|
||||
|
|
@ -1080,6 +1086,13 @@ func (c *Client) ProcessIncomingMessage(chatId int64, message *client.Message) {
|
|||
}
|
||||
text = newText.String()
|
||||
}
|
||||
|
||||
if oobSwap {
|
||||
if !ignorePrefix {
|
||||
auxText = text
|
||||
}
|
||||
text = oob
|
||||
}
|
||||
}
|
||||
}
|
||||
if !replyObtained {
|
||||
|
|
|
|||
Loading…
Reference in a new issue