forked from MTSR/telegram
Доработать мод:
- руссификация; - привязка отправки сообщения в конкретный топик.
This commit is contained in:
parent
d99eecd773
commit
499967bf52
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/.idea/
|
@ -4,4 +4,4 @@
|
||||
* telegram.timeout -- update periodicity. The bot does check for the new messages with this timeout, but the in-game messages are sent to telegram immediately. Increase for better performance.
|
||||
* telegram.announce_mode -- announce player joining or leaving. Available options: none, privileged, all. Priviliged means interact for now. Player deaths may be announced in the future, but not yet.
|
||||
* telegram.message_color -- color of the telegram messages in the in-game chat
|
||||
|
||||
* telegram.message_thread_id - unique identifier (Integer) of a message thread to which the message belongs; for supergroups only
|
||||
|
10
init.lua
10
init.lua
@ -1,3 +1,5 @@
|
||||
local S = minetest.get_translator("telegram")
|
||||
|
||||
local current_mod_name = minetest.get_current_modname()
|
||||
local modpath = minetest.get_modpath(current_mod_name)
|
||||
|
||||
@ -84,7 +86,7 @@ local function process_updates(response)
|
||||
http_in_progress = false
|
||||
end
|
||||
|
||||
function telegram.send_message(chat_id, text)
|
||||
function telegram.send_message(chat_id, text, message_thread_id)
|
||||
local allowed_parse_mode = {
|
||||
["Markdown"] = true,
|
||||
["HTML"] = true
|
||||
@ -165,7 +167,7 @@ end)
|
||||
-- Don't send messages from MT to telegram if we don't know where to
|
||||
if chat_id then
|
||||
minetest.register_on_chat_message(function(name, message)
|
||||
telegram.send_message(chat_id, "<" .. name .. "> " .. message)
|
||||
telegram.send_message(chat_id, "<" .. name .. "> " .. message, message_thread_id)
|
||||
return false
|
||||
end)
|
||||
|
||||
@ -173,14 +175,14 @@ if chat_id then
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
if announce_mode == ANNOUNCE_ALL or minetest.check_player_privs(name, "interact") then
|
||||
telegram.send_message(chat_id, name .. " joined the game.")
|
||||
telegram.send_message(chat_id, name .. S(" joined the game."), message_thread_id)
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player, timed_out)
|
||||
local name = player:get_player_name()
|
||||
if announce_mode == ANNOUNCE_ALL or minetest.check_player_privs(name, "interact") then
|
||||
telegram.send_message(chat_id, name .. " left the game.")
|
||||
telegram.send_message(chat_id, name .. S(" left the game."), message_thread_id)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
4
locale/telegram.ru.tr
Normal file
4
locale/telegram.ru.tr
Normal file
@ -0,0 +1,4 @@
|
||||
# textdomain: telegram
|
||||
|
||||
joined the game.= вошёл в игру.
|
||||
left the game.= покинул игру.
|
Loading…
Reference in New Issue
Block a user