You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
4.4 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. ## Telegabber: like Zhabogram, but in Go! ##
  2. Now it's native, more asynchronous, and does not require to mess your server up with a monstrous third-party interpreter.
  3. The configuration file is compatible with Zhabogram 2.0, so you can easily copy your existing `config.yml`.
  4. ### Build ###
  5. Prerequisites: Go links the binary against the `glibc` version present in the system where the build process happens, so it should be less or equal to the version of `glibc` in the system where Telegabber will run.
  6. * Build TDLib according to [TDLib build instructions](https://tdlib.github.io/td/build.html). Roll back to commit 8d7bda00a535d1eda684c3c8802e85d69c89a14a if the compatibility got broken.
  7. * Install Go (tested with 1.13, but may work with earlier versions too).
  8. * Open the source dir in a new shell (to make sure that `$GOPATH` works) and run `make`. Dependencies will be installed automatically.
  9. After a successful build, you get a single binary to deploy on your server.
  10. In the deploy directory, you need only three files:
  11. * `telegabber` (the binary)
  12. * `config.yml`
  13. * `config_schema.json` (copy it from the repo)
  14. ### Installation ###
  15. A third-party Docker config was prepared to set up telegabber+Prosody: https://github.com/e1z0/telegabber-docker/
  16. **Hard way:**
  17. First of all, you need to create component listener on your Jabber server.
  18. For example, for ejabberd in **/etc/ejabberd/ejabberd.yml**:
  19. ```
  20. listen:
  21. -
  22. port: 8888
  23. module: ejabberd_service
  24. access: all
  25. shaper_rule: fast
  26. ip: "127.0.0.1"
  27. service_check_from: false
  28. hosts:
  29. "tlgrm.localhost":
  30. password: "secret"
  31. ```
  32. Next, rename **config.yml.example** to **config.yml** and edit **xmpp** section to match your component listener:
  33. ```
  34. :xmpp:
  35. db 'users.db'
  36. jid: 'tlgrm.localhost'
  37. host: 'localhost'
  38. port: 8888
  39. secret: 'secret'
  40. loglevel: :warn
  41. ```
  42. ### Configuration ###
  43. It is good idea to obtain Telegram API ID from [**https://my.telegram.org**](https://my.telegram.org) to remove demo key requests limit, and then edit in **config.yml**:
  44. ```
  45. :telegram:
  46. :tdlib:
  47. :client:
  48. :api_id: '845316' # telegram API ID (my.telegram.org) #
  49. :api_hash: '27fe5224bc822bf3a45e015b4f9dfdb7' # telegram API HASH (my.telegram.org) #
  50. ...
  51. ```
  52. ### Arguments ###
  53. * `--profiling-port=xxxx`: start the pprof server on port `xxxx`. Access is limited to localhost.
  54. * `--config=/bla/bla/config.yml`: set the config file path (default: `config.yml`).
  55. * `--schema=/bla/bla/schema.json`: set the schema file path (default: `./config_schema.json`).
  56. ### How to receive files from Telegram ###
  57. First of all, you need to set up web server that will serve some directory in your filesystem.
  58. Example nginx config:
  59. ```
  60. server {
  61. listen 80;
  62. server_name tlgrm.localhost;
  63. location /content {
  64. alias /var/zhabogram;
  65. }
  66. }
  67. ```
  68. You need to set `:content: → :path: and :link:` **config.yml**.
  69. Set `:path:` according to location (for our example it will be `/var/zhabogram/content`).
  70. Set `:link:` according to server_name (for our example it will be `http://tlgrm.localhost`)
  71. ### How to send files to Telegram chats ###
  72. You need to setup `mod_http_upload` for your XMPP server.
  73. For example, for ejabberd in **/etc/ejabberd/ejabberd.yml**
  74. ```
  75. modules:
  76. mod_http_upload:
  77. docroot: "/var/ejabberd/upload" # this must be a valid path, user ownership and SELinux flags must be set accordingly
  78. put_url: "https://xmpp.localhost:5443/upload/@HOST@"
  79. get_url: "https://xmppfiles.localhost/upload/@HOST@"
  80. access: local
  81. max_size: 500000000 #500 MByte
  82. thumbnail: false
  83. file_mode: "0644"
  84. dir_mode: "0744"
  85. ```
  86. Then you need to setup nginx proxy that will serve `get_url` path, because Telegram will not handle URLs with non-default http(s) ports.
  87. Example nginx config:
  88. ```
  89. server {
  90. listen 80;
  91. listen 443 ssl;
  92. server_name xmppfiles.localhost;
  93. # SSL settigns #
  94. keepalive_timeout 60;
  95. ssl_certificate /etc/ssl/domain.crt;
  96. ssl_certificate_key /etc/ssl/domain.key;
  97. ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
  98. ssl_ciphers "RC4:HIGH:!aNULL:!MD5:!kEDH";
  99. add_header Strict-Transport-Security 'max-age=604800';
  100. location / {
  101. proxy_pass https://xmpp.localhost:5443;
  102. }
  103. }
  104. ```
  105. Finally, update `:upload:` in your config.yml to match `server_name` in nginx config.