This repository has been archived on 2024-05-28. You can view files and clone it, but cannot push or open issues or pull requests.
zhabogram/README.md

123 lines
3.2 KiB
Markdown
Raw Normal View History

2019-04-16 04:53:31 +00:00
### Dependencies ###
* Ruby >= 1.9
* xmpp4r == 0.5.6
* tdlib-ruby == 2.0 with pre-compiled _libtdjson.so_
2019-04-16 06:32:51 +00:00
There is pre-compiled _libtdjson.so_ for Debian Stretch x64 in repository.
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**).
2019-04-16 04:53:31 +00:00
### Installation ###
First of all, you need to create component listener on your Jabber server.
2019-04-16 06:09:34 +00:00
For example, for ejabberd in **/etc/ejabberd/ejabberd.yml**:
2019-04-16 04:53:31 +00:00
2019-04-16 05:45:25 +00:00
```
2019-04-16 06:09:34 +00:00
listen:
-
port: 8888
module: ejabberd_service
access: all
shaper_rule: fast
ip: "127.0.0.1"
service_check_from: false
hosts:
"tlgrm.localhost":
2019-04-16 06:09:34 +00:00
password: "secret"
2019-04-16 04:53:31 +00:00
```
2019-04-16 06:32:51 +00:00
Next, rename **config.yml.example** to **config.yml** and edit **xmpp** section to match your component listener:
2019-04-16 04:53:31 +00:00
2019-04-16 05:45:25 +00:00
2019-04-16 04:53:31 +00:00
```
:xmpp:
db 'users.db'
jid: 'tlgrm.localhost'
2019-04-16 05:46:37 +00:00
host: 'localhost'
port: 8888
secret: 'secret'
loglevel: :warn
2019-04-16 04:53:31 +00:00
```
2019-04-16 06:09:34 +00:00
### Configuration ###
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**:
```
:telegram:
:tdlib:
:lib_path: 'lib/'
:client:
:api_id: '845316' # telegram API ID (my.telegram.org) #
:api_hash: '27fe5224bc822bf3a45e015b4f9dfdb7' # telegram API HASH (my.telegram.org) #
...
```
2019-04-16 06:09:34 +00:00
### 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 :link:` **config.yml**.
2019-04-16 06:09:34 +00:00
Set `:path:` according to location (for our example it will be `/var/zhabogram/content`).
Set `:link:` according to server_name (for our example it will be `http://tlgrm.localhost`)
2019-04-16 06:09:34 +00:00
### 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"
```
2019-04-16 06:33:53 +00:00
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.
2019-04-16 06:09:34 +00:00
Example nginx config:
/```
2019-04-16 06:09:34 +00:00
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;
}
}
```
Finally, update `:upload:` in your config.yml to match `server_name` in nginx config.