File tree Expand file tree Collapse file tree 3 files changed +57
-5
lines changed Expand file tree Collapse file tree 3 files changed +57
-5
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,8 @@ tnt-tg-bot - это библиотека, написанная на Lua для
24
24
25
25
### Автоматическая
26
26
1 . Установите ` git ` , ` curl ` , ` lua 5.1 ` и ` luarocks ` .
27
- 2 . (опционально) если потребуется работа с Web App:
28
- Потребуется установить rock пакет ` luaossl ` , для него в вашем дистрибутиве -
27
+ 2 . (опционально) если потребуется работа с Web App: </ br >
28
+ Потребуется установить rock пакет ` luaossl ` , для него в вашем дистрибутиве - </ br >
29
29
установите заголовочные файлы для ` lua 5.1 ` и ` openssl ` .
30
30
2 . Установите [ tarantool] ( https://www.tarantool.io/ru/download/os-installation )
31
31
3 . Выполните скрипт автоматической установки необходимых пакетов
Original file line number Diff line number Diff line change @@ -35,9 +35,8 @@ bash tnt-tg-bot.pre-build.sh
35
35
5 . If issues occur, proceed with the manual installation.
36
36
37
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
38
+ > To successfully build luaossl (OpenSSL bindings), development headers for ` OpenSSL ` and ` Lua 5.1 ` are required. </br >
39
+ > On Ubuntu, install them with: ` sudo apt install libssl-dev liblua5.1-0-dev ` </br >
41
40
> luaossl is required by the module bot/libs/parseInitData.lua, which handles Telegram Mini App initialization data.
42
41
> https://core.telegram.org/bots/webapps#validating-data-received-via-the-mini-app
43
42
Original file line number Diff line number Diff line change
1
+ -- Example of echo bot via webhook
2
+ --
3
+ local log = require (' log' )
4
+ local bot = require (' bot' )
5
+ local parse_mode = require (' bot.enums.parse_mode' )
6
+ local methods = require (' bot.enums.methods' )
7
+
8
+ bot :cfg ({
9
+ token = os.getenv (' BOT_TOKEN' ),
10
+ parse_mode = parse_mode .HTML
11
+ })
12
+
13
+ function bot .events .onGetUpdate (ctx )
14
+ local text = ctx :getText ()
15
+ local chatId = ctx :getChatId ()
16
+
17
+ local _ , err = bot .call (methods .sendMessage , {
18
+ text = text ,
19
+ chat_id = chatId
20
+ })
21
+
22
+ if err then
23
+ log .error ({
24
+ error = err
25
+ })
26
+ end
27
+ end
28
+
29
+ bot :startWebHook ({
30
+ -- Server setup
31
+ host = ' 0.0.0.0' ,
32
+ port = 8077 ,
33
+
34
+ -- Bot setup
35
+ drop_pending_updates = true ,
36
+ allowed_updates = {
37
+ " message" ,
38
+ " chat_member" , " my_chat_member" ,
39
+ " callback_query" ,
40
+ " pre_checkout_query"
41
+ },
42
+
43
+ bot_url = ' https://sitename.io/bots/mybot'
44
+
45
+ -- If you don't have a domain name
46
+ -- you will need to use a self-signed certificate
47
+ -- https://core.telegram.org/bots/self-signed
48
+ --
49
+ --
50
+ -- bot_url = 'https://180.10.120.240/bots/mybot',
51
+ -- path to custom certificate
52
+ -- certificate = '/etc/www/cert/public.pem'
53
+ })
You can’t perform that action at this time.
0 commit comments