diff --git a/README.md b/README.md index d5880ad..c7943ce 100644 --- a/README.md +++ b/README.md @@ -10,18 +10,20 @@ ### Installation ### First of all, you need to create component listener on your Jabber server. -For example, for ejabberd: +For example, for ejabberd in **/etc/ejabberd/ejabberd.yml**: ``` -port: 8888 -module: ejabberd_service -access: all -shaper_rule: fast -ip: "127.0.0.1" -service_check_from: false -hosts: - "telegram.jabber.ru": - password: "secret" +listen: + - + port: 8888 + module: ejabberd_service + access: all + shaper_rule: fast + ip: "127.0.0.1" + service_check_from: false + hosts: + "telegram.jabber.ru": + password: "secret" ``` @@ -38,4 +40,72 @@ xmpp: loglevel: 0 ``` -If neccessary, edit **telegram** section too. +### Configuration ### + +Feel free to edit **config.yml**, options are commented and with clear names. +It is good idea to obtain Telegram API ID from [my.telegram.org](https://my.telegram.org) to remove demo key requests limit. + +### How to receive files from Telegram ### + +First of all, you need to set up web server that will serve some directory in your filesystem. +Example nginx config: + +``` +server { + listen 80; + server_name tlgrm.localhost; + location /content { + alias /var/zhabogram; + } +} +``` + +You need to set `content_path` and `content_link` in **config.yml**. + +Set `content_path` according to location (for our example it will be `/var/zhabogram/content`). +Set `content_link` according to server_name (for our example it will be `http://tlgrm.localhost`) + + +### How to send files to Telegram chats ### + +You need to setup `mod_http_upload` for your XMPP server. +For example, for ejabberd in **/etc/ejabberd/ejabberd.yml** + +``` +modules: + mod_http_upload: + docroot: "/var/ejabberd/upload" # this must be a valid path, user ownership and SELinux flags must be set accordingly + put_url: "https://xmpp.localhost:5443/upload/@HOST@" + get_url: "https://xmppfiles.localhost/upload/@HOST@" + access: local + max_size: 500000000 #500 MByte + thumbnail: false + file_mode: "0644" + dir_mode: "0744" +``` + +Then you need to setup nginx proxy that will serve `get_url` path, because Telegram do not allowing URLs with non-default ports. +Example nginx config: + +``` +server { + listen 80; + listen 443 ssl; + + server_name xmppfiles.localhost; + + # SSL settigns # + keepalive_timeout 60; + ssl_certificate /etc/ssl/domain.crt; + ssl_certificate_key /etc/ssl/domain.key; + ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2; + ssl_ciphers "RC4:HIGH:!aNULL:!MD5:!kEDH"; + add_header Strict-Transport-Security 'max-age=604800'; + + location / { + proxy_pass https://xmpp.localhost:5443; + } + +} + +``` diff --git a/config.yml.example b/config.yml.example index bc16064..c5cb042 100644 --- a/config.yml.example +++ b/config.yml.example @@ -1,21 +1,22 @@ telegram: - api_id: '17349' - api_hash: '344583e45741c457fe1862106095a5eb' - verbosity: 2 - useragent: 'Zhabogram XMPP Gateway' - version: '0.7' - use_test_dc: false - loglevel: 0 - content_path: '/var/www/tg_media' - content_link: 'https://localhost/tg_media' - content_upload_prefix: 'https://localhost/upload' + api_id: '17349' # telegram API ID (my.telegram.org) # + api_hash: '344583e45741c457fe1862106095a5eb' # telegram API HASH (my.telegram.org) # + verbosity: 2 # 1 = no verbosity, 2 = moderate verbosity, 3 = network requests debug + useragent: 'Zhabogram XMPP Gateway' # client name + version: '0.8' # client version + use_test_dc: false # always use false + loglevel: 0 # 0 = debug, 1 = info, 2 = warn, 3 = err, 4 = fatal, 5 = unknown (ruby logger class) + content_path: '/var/www/tg_media' # we will move (symlink) downloaded content here — you must setup web server that serve this directry + content_link: 'https://localhost/tg_media' # web server that serve `content_path` internet address + content_upload_prefix: 'https://localhost/upload' # we will send files with URL starting with this string as document to Telegram (mod_http_upload get_url, see readme) xmpp: - db_path: 'users.db' - jid: 'tlgrm.localhost' - host: 'localhost' - port: 8899 - secret: 'password' - loglevel: 0 + db_path: 'users.db' # sqlite3 users (JID:Telegram Login) database + jid: 'tlgrm.localhost' # component JID + host: 'localhost' # XMPP server + port: 8899 # component port + secret: 'password' # component auth secret + loglevel: 0 # 0 = debug, 1 = info, 2 = warn, 3 = err, 4 = fatal, 5 = unknown (ruby logger class) +