Added filtering of messages by chat topic

This commit is contained in:
Vitaliy Olkhin 2024-10-10 13:14:59 +05:00
parent d99eecd773
commit 1000540ef9
2 changed files with 55 additions and 1 deletions

42
.gitignore vendored Normal file
View File

@ -0,0 +1,42 @@
# Compiled Lua sources
luac.out
# luarocks build files
*.src.rock
*.zip
*.tar.gz
# Object files
*.o
*.os
*.ko
*.elf
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
*.def
*.exp
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
.idea
*.iml

View File

@ -10,7 +10,7 @@ telegram = {}
local token = minetest.settings:get("telegram.token")
local chat_id = minetest.settings:get("telegram.chatid")
local updates_timeout = tonumber(minetest.settings:get("telegram.timeout"))
local message_thread_id = minetest.settings:get("telegram.message_thread_id")
local message_thread_id = tonumber(minetest.settings:get("telegram.message_thread_id"))
if not updates_timeout then
updates_timeout = 1
@ -121,6 +121,18 @@ function telegram.on_text_receive(msg)
if command then
command(msg)
else
if message_thread_id then
if msg.message_thread_id == nil then
minetest.log("action", "telegram: message_thread_id not equal 'nil'")
return
end
if msg.message_thread_id ~= message_thread_id then
minetest.log("action", "telegram: message_thread_id not equal " .. msg.message_thread_id)
return
end
end
local message_text = msg.text
if msg.reply_to_message and msg.reply_to_message.text then
message_text = ">>" .. msg.reply_to_message.text .. "\n" .. message_text