forked from MTSR/telegram
Removed name suffixes, allow changing color for TG messages in-game
This commit is contained in:
parent
c404aee07c
commit
4726824c3e
@ -3,4 +3,5 @@
|
|||||||
* telegram.chatid -- id of the chat you will relay messages to. You can start the bot without it and send groupid command to get it later.
|
* telegram.chatid -- id of the chat you will relay messages to. You can start the bot without it and send groupid command to get it later.
|
||||||
* 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.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.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
|
||||||
|
|
||||||
|
7
init.lua
7
init.lua
@ -19,6 +19,7 @@ local announce_mode = minetest.settings:get("telegram.announce_mode")
|
|||||||
if not announce_mode then
|
if not announce_mode then
|
||||||
announce_mode = ANNOUNCE_NONE
|
announce_mode = ANNOUNCE_NONE
|
||||||
end
|
end
|
||||||
|
local message_color = minetest.settings:get("telegram.message_color") or "#339933"
|
||||||
|
|
||||||
if not token then
|
if not token then
|
||||||
error("Bot token should be specified in the config in order to work.")
|
error("Bot token should be specified in the config in order to work.")
|
||||||
@ -122,7 +123,7 @@ function telegram.on_text_receive(msg)
|
|||||||
if msg.reply_to_message and msg.reply_to_message.text then
|
if msg.reply_to_message and msg.reply_to_message.text then
|
||||||
message_text = ">>" .. msg.reply_to_message.text .. "\n" .. message_text
|
message_text = ">>" .. msg.reply_to_message.text .. "\n" .. message_text
|
||||||
end
|
end
|
||||||
minetest.chat_send_all("<" .. msg.from.first_name .. "@TG> " .. message_text)
|
minetest.chat_send_all(minetest.colorize(message_color, "<" .. msg.from.first_name .. "> " .. message_text))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -137,7 +138,7 @@ function telegram.notify_non_text_receive(message)
|
|||||||
payload = 'sticker'
|
payload = 'sticker'
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.chat_send_all(message.from.first_name .. "@TG sent " .. payload)
|
minetest.chat_send_all(minetest.colorize(message_color, message.from.first_name .. " sent " .. payload))
|
||||||
end
|
end
|
||||||
|
|
||||||
local timer = 0
|
local timer = 0
|
||||||
@ -163,7 +164,7 @@ end)
|
|||||||
-- Don't send messages from MT to telegram if we don't know where to
|
-- Don't send messages from MT to telegram if we don't know where to
|
||||||
if chat_id then
|
if chat_id then
|
||||||
minetest.register_on_chat_message(function(name, message)
|
minetest.register_on_chat_message(function(name, message)
|
||||||
telegram.send_message(chat_id, "<" .. name .. "@MT> " .. message)
|
telegram.send_message(chat_id, "<" .. name .. "> " .. message)
|
||||||
return false
|
return false
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user