Skip to content

Commit 0732418

Browse files
committed
Updated installation
1 parent dcc5168 commit 0732418

File tree

4 files changed

+79
-34
lines changed

4 files changed

+79
-34
lines changed

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,43 @@ tnt-tg-bot - это библиотека, написанная на Lua для
2222

2323
## Установка
2424

25-
### Предварительная сборка
25+
### Автоматическая
26+
1. Установите `git`, `curl`, `lua 5.1` и `luarocks`.
27+
2. (опционально) если потребуется работа с Web App:
28+
Потребуется установить rock пакет `luaossl`, для него в вашем дистрибутиве -
29+
установите заголовочные файлы для `lua 5.1` и `openssl`.
30+
2. Установите [tarantool](https://www.tarantool.io/ru/download/os-installation)
31+
3. Выполните скрипт автоматической установки необходимых пакетов
2632
```bash
2733
bash tnt-tg-bot.pre-build.sh
2834
```
35+
5. В случае проблем, перейти к ручной установки.
2936

37+
> [!NOTE]
38+
> Для успешной сборки `luaossl` - биндинга к OpenSSL, потребуются заголовочные файлы OpenSSL и Lua 5.1.
39+
> В Ubuntu можно установить, выполнив `sudo apt install libssl-dev liblua5.1-0-dev`.
40+
> `luaossl` нужен для работы модуля `bot/libs/parseInitData.lua`, модуль нужен для обработки данных веб Mini App.
41+
> https://core.telegram.org/bots/webapps#validating-data-received-via-the-mini-app
42+
43+
### Ручная
44+
1. Установите `git`, `curl`, `lua 5.1` и `luarocks`.
45+
2. Установите [tarantool](https://www.tarantool.io/ru/download/os-installation)
46+
3. (опционально) если потребуется работа с Web App: </br>
47+
Потребуется установить rock пакет `luaossl`, для него в вашем дистрибутиве - </br>
48+
установите заголовочные файлы для `lua 5.1` и `openssl`.
49+
4. Установка необходимых пакетов с помощью `luarocks`
50+
+ **HTTP клиент/сервер (обязательно)**
51+
```bash
52+
luarocks install --local --tree=$PWD/.rocks --server=https://rocks.tarantool.org/ http
53+
```
54+
+ **Multipart Post обработчик (обязательно)**
55+
```bash
56+
luarocks install --local --tree=$PWD/.rocks --lua-version 5.1 lua-multipart-post 1.0-0
57+
```
58+
+ **Биндинг к openssl (опционально)**
59+
```bash
60+
luarocks install --local --tree=$PWD/.rocks --lua-version 5.1 luaossl
61+
```
3062
## Примеры
3163
+ `examples/echo-bot.lua` - Простой эхо-бот
3264
+ `examples/ping-pong.lua` - Реакция на команду /ping

README_EN.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,44 @@ Due to the simple and clear architecture, adding missing functionality is straig
2222

2323
## Installation
2424

25-
### Pre-build
25+
### Automated Installation
26+
1. Install `git`, `curl`, `lua 5.1` and `luarocks`.
27+
2. (Optional) If Web App support is needed: </br>
28+
You’ll need the `luaossl` rock package. </br>
29+
To build it, install development headers for `lua 5.1` and `openssl` from your distribution.
30+
2. Install [tarantool](https://www.tarantool.io/en/download/os-installation)
31+
3. Run the automatic setup script
2632
```bash
2733
bash tnt-tg-bot.pre-build.sh
2834
```
35+
5. If issues occur, proceed with the manual installation.
36+
37+
> [!NOTE]
38+
> To successfully build luaossl (OpenSSL bindings), development headers for OpenSSL and Lua 5.1 are required.
39+
> On Ubuntu, install them with:
40+
> sudo apt install libssl-dev liblua5.1-0-dev
41+
> luaossl is required by the module bot/libs/parseInitData.lua, which handles Telegram Mini App initialization data.
42+
> https://core.telegram.org/bots/webapps#validating-data-received-via-the-mini-app
43+
44+
### Manual Installationc
45+
1. Install `git`, `curl`, `lua 5.1` and `luarocks`.
46+
2. Install [tarantool](https://www.tarantool.io/en/download/os-installation)
47+
3. (Optional) If Web App support is needed: </br>
48+
You’ll need the `luaossl` rock package. </br>
49+
To build it, install development headers for `lua 5.1` and `openssl` from your distribution.
50+
4. Install required packages via `luarocks`
51+
+ **HTTP client/server (required)**
52+
```bash
53+
luarocks install --local --tree=$PWD/.rocks --server=https://rocks.tarantool.org/ http
54+
```
55+
+ **Multipart Post обработчик (required)**
56+
```bash
57+
luarocks install --local --tree=$PWD/.rocks --lua-version 5.1 lua-multipart-post 1.0-0
58+
```
59+
+ **OpenSSL bindings (optional)**
60+
```bash
61+
luarocks install --local --tree=$PWD/.rocks --lua-version 5.1 luaossl
62+
```
2963

3064
## Examples
3165
+ `examples/echo-bot.lua` - Simple echo bot

bot/init.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
--- @module bot
77
local bot = { _version = '1.0.0' }
88

9+
package.path = package.path .. ';.rocks/share/lua/5.1/?.lua'
10+
package.cpath = package.cpath .. ';.rocks/lib/lua/5.1/?.so'
11+
912
local log = require('log')
1013
local fio = require('fio')
1114
local json = require('json')

tnt-tg-bot.pre-build.sh

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ install() {
3737
printf "Install ${C_INSTALL}${1}${C_RESET}...\n"
3838
}
3939

40-
basic_programs=(tarantool unzip lua git gcc)
41-
optional_programs=(ldoc luacheck luarocks tt tarantoolctl)
40+
basic_programs=(tarantool luarocks unzip lua git gcc)
41+
optional_programs=(ldoc luacheck curl openssl)
4242
errs=0
4343

4444
for ((i = 0; i < ${#basic_programs[*]}; ++i)); do
@@ -56,55 +56,31 @@ if [ $errs -ge 1 ]; then
5656
exit 1
5757
fi
5858

59-
# Проверяем наличие tt или tarantoolctl
60-
has_tt=false
61-
has_tarantoolctl=false
62-
6359
for ((i = 0; i < ${#optional_programs[*]}; ++i)); do
6460
programm="${optional_programs[$i]}"
6561

6662
if [ "$(which -a $programm . 2>/dev/null)" ]; then
6763
info "${programm} (optional)"
68-
69-
if [ "$programm" == "tt" ]; then
70-
has_tt=true
71-
fi
72-
73-
if [ "$programm" == "tarantoolctl" ]; then
74-
has_tarantoolctl=true
75-
fi
7664
else
7765
echo "Warning: ${programm} not found"
7866
fi
7967
done
8068

81-
# Определяем, какую команду использовать для установки
82-
if [ "$has_tt" = true ]; then
83-
ROCKS_CMD="tt rocks"
84-
info "Using tt for package installation"
85-
elif [ "$has_tarantoolctl" = true ]; then
86-
ROCKS_CMD="tarantoolctl rocks"
87-
warning "tt not found, using tarantoolctl instead"
88-
else
89-
error "Neither tt nor tarantoolctl found. Cannot install packages."
90-
exit 1
91-
fi
92-
9369
# Install all rocks
9470
echo
95-
install "OpenSSL"
96-
$ROCKS_CMD install --server=https://luarocks.org luaossl
9771
install "http"
98-
$ROCKS_CMD install --server=https://rocks.tarantool.org/ --local http
72+
luarocks install --local --tree=$PWD/.rocks --server=https://rocks.tarantool.org/ http
9973
install "lua-multipart-post"
100-
$ROCKS_CMD install --server=https://luarocks.org lua-multipart-post 1.0-0
74+
luarocks install --local --tree=$PWD/.rocks --lua-version 5.1 lua-multipart-post 1.0-0
75+
install "luaosll"
76+
luarocks install --local --tree=$PWD/.rocks --lua-version 5.1 luaossl
10177

10278
while [[ $# -gt 0 ]]; do
10379
case "$1" in
10480
-o | --optional)
10581
install "pimp"
106-
$ROCKS_CMD install --server=https://luarocks.org pimp
82+
luarocks install pimp
10783
shift 1
10884
;;
10985
esac
110-
done
86+
done

0 commit comments

Comments
 (0)