7a04f298d2
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
60 lines
1.2 KiB
Go
60 lines
1.2 KiB
Go
// Binary dlkey extracts public keys from remote repo.
|
|
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"io"
|
|
"net/http"
|
|
"net/url"
|
|
"os"
|
|
"path"
|
|
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/keyparser"
|
|
)
|
|
|
|
func main() {
|
|
var (
|
|
name = flag.String("f", "mtproto_dc_options.cpp", "file name to download")
|
|
base = flag.String("base", "https://raw.githubusercontent.com/telegramdesktop/tdesktop", "base url")
|
|
branch = flag.String("branch", "dev", "branch to use")
|
|
dir = flag.String("dir", "Telegram/SourceFiles/mtproto/", "directory")
|
|
out = flag.String("o", "", "output file name (blank to stdout)")
|
|
)
|
|
flag.Parse()
|
|
|
|
u, err := url.Parse(*base)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
u.Path = path.Join(u.Path, *branch, *dir, *name)
|
|
|
|
res, err := http.Get(u.String())
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer func() { _ = res.Body.Close() }()
|
|
if res.StatusCode/100 != 2 {
|
|
panic(fmt.Sprintf("status code %d", res.StatusCode))
|
|
}
|
|
|
|
var outWriter io.Writer = os.Stdout
|
|
if *out != "" {
|
|
w, err := os.Create(*out)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer func() {
|
|
if err := w.Close(); err != nil {
|
|
panic(err)
|
|
}
|
|
}()
|
|
outWriter = w
|
|
}
|
|
|
|
if err := keyparser.Extract(res.Body, outWriter); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|