Jabber transport to Telegram network
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.

README.md 3.2KB

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. ### Dependencies ###
  2. * Ruby >= 1.9
  3. * xmpp4r == 0.5.6
  4. * tdlib-ruby == 2.0 with pre-compiled _libtdjson.so_
  5. There is pre-compiled _libtdjson.so_ for Debian Stretch x64 in repository.
  6. For any other distro you need to manually compile [**tdlib**](https://github.com/tdlib/td) and place _libtdjson.so_ to relative **lib/** directory (or **LD_LIBRARY_PATH**).
  7. ### Installation ###
  8. First of all, you need to create component listener on your Jabber server.
  9. For example, for ejabberd in **/etc/ejabberd/ejabberd.yml**:
  10. ```
  11. listen:
  12. -
  13. port: 8888
  14. module: ejabberd_service
  15. access: all
  16. shaper_rule: fast
  17. ip: "127.0.0.1"
  18. service_check_from: false
  19. hosts:
  20. "tlgrm.localhost":
  21. password: "secret"
  22. ```
  23. Next, rename **config.yml.example** to **config.yml** and edit **xmpp** section to match your component listener:
  24. ```
  25. :xmpp:
  26. db 'users.db'
  27. jid: 'tlgrm.localhost'
  28. host: 'localhost'
  29. port: 8888
  30. secret: 'secret'
  31. loglevel: :warn
  32. ```
  33. ### Configuration ###
  34. 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**:
  35. ```
  36. :telegram:
  37. :tdlib:
  38. :lib_path: 'lib/'
  39. :client:
  40. :api_id: '845316' # telegram API ID (my.telegram.org) #
  41. :api_hash: '27fe5224bc822bf3a45e015b4f9dfdb7' # telegram API HASH (my.telegram.org) #
  42. ...
  43. ```
  44. ### How to receive files from Telegram ###
  45. First of all, you need to set up web server that will serve some directory in your filesystem.
  46. Example nginx config:
  47. ```
  48. server {
  49. listen 80;
  50. server_name tlgrm.localhost;
  51. location /content {
  52. alias /var/zhabogram;
  53. }
  54. }
  55. ```
  56. You need to set `:content: → :path: and :link:` **config.yml**.
  57. Set `:path:` according to location (for our example it will be `/var/zhabogram/content`).
  58. Set `:link:` according to server_name (for our example it will be `http://tlgrm.localhost`)
  59. ### How to send files to Telegram chats ###
  60. You need to setup `mod_http_upload` for your XMPP server.
  61. For example, for ejabberd in **/etc/ejabberd/ejabberd.yml**
  62. ```
  63. modules:
  64. mod_http_upload:
  65. docroot: "/var/ejabberd/upload" # this must be a valid path, user ownership and SELinux flags must be set accordingly
  66. put_url: "https://xmpp.localhost:5443/upload/@HOST@"
  67. get_url: "https://xmppfiles.localhost/upload/@HOST@"
  68. access: local
  69. max_size: 500000000 #500 MByte
  70. thumbnail: false
  71. file_mode: "0644"
  72. dir_mode: "0744"
  73. ```
  74. 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.
  75. Example nginx config:
  76. /```
  77. server {
  78. listen 80;
  79. listen 443 ssl;
  80. server_name xmppfiles.localhost;
  81. # SSL settigns #
  82. keepalive_timeout 60;
  83. ssl_certificate /etc/ssl/domain.crt;
  84. ssl_certificate_key /etc/ssl/domain.key;
  85. ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
  86. ssl_ciphers "RC4:HIGH:!aNULL:!MD5:!kEDH";
  87. add_header Strict-Transport-Security 'max-age=604800';
  88. location / {
  89. proxy_pass https://xmpp.localhost:5443;
  90. }
  91. }
  92. ```
  93. Finally, update `:upload:` in your config.yml to match `server_name` in nginx config.