diff --git a/bot/seedbot.lua b/bot/seedbot.lua index d2fb42d..eee3fdf 100644 --- a/bot/seedbot.lua +++ b/bot/seedbot.lua @@ -219,7 +219,8 @@ function create_config( ) "download_media", "invite", "all", - "leave_ban" + "leave_ban", + "block_user" }, sudo_users = {110626080,103649648,111020322,0,tonumber(our_id)},--Sudo users disabled_channels = {}, diff --git a/plugins/block_user.lua b/plugins/block_user.lua new file mode 100644 index 0000000..837cba1 --- /dev/null +++ b/plugins/block_user.lua @@ -0,0 +1,18 @@ +local function run(msg, matches) + if matches[1] == "block" then + local user_id = "user#id"..matches[2] + block_user(user_id, ok_cb, false) + end + if matches[1] == "unblock" then + local user_id = "user#id"..matches[2] + unblock_user(user_id, ok_cb, false) + end +end + +return { + patterns = { + "^[!/](block) (.*)$", + "^[!/](unblock) (.*)$" + }, + run = run +} diff --git a/plugins/inpm.lua b/plugins/inpm.lua index 86048a3..a9fce14 100644 --- a/plugins/inpm.lua +++ b/plugins/inpm.lua @@ -35,15 +35,12 @@ local function chat_list(msg) file:flush() file:close() return message - end - -function run(msg, matches) +local function run(msg, matches) if msg.to.type ~= 'chat' or is_sudo(msg) or is_admin(msg) and is_realm(msg) then local data = load_data(_config.moderation.data) if matches[1] == 'join' and data[tostring(matches[2])] then - if data[tostring(matches[2])]['settings']['public'] == 'no' then if is_banned(msg.from.id, matches[2]) then return 'You are banned.' end @@ -53,41 +50,37 @@ function run(msg, matches) if data[tostring(matches[2])]['settings']['lock_member'] == 'yes' and not is_owner2(msg.from.id, matches[2]) then return 'Group is private.' end - local chat = "chat#id"..matches[2] - local user = "user#id"..msg.from.id - chat_add_user(chat, user, ok_cb, false) - else - return "Chat not found." + local chat_id = "chat#id"..matches[2] + local user_id = "user#id"..msg.from.id + chat_add_user(chat_id, user_id, ok_cb, false) + local group_name = data[tostring(matches[2])]['settings']['set_name'] + return "Added you to chat:\n\n👥"..group_name.." (ID:"..matches[2]..")" + elseif matches[1] == 'join' and not data[tostring(matches[2])] then + + return "Chat not found." end - end - -- SERVICE MESSAGE IN GROUP - --[[if msg.action and msg.action.type then - local action = msg.action.type - local receiver = 'user#id'..msg.action.user.id - local group_name = string.gsub(msg.to.print_name, '_', ' ') - --Check if user from pm joins chat via bot - if action == "chat_add_user" and msg.action.to == matches[2] and msg.from.id == 0 then - print ("Added "..msg.action.user.id.." to chat "..msg.to.print_name.." (ID:"..msg.to.id..")") - savelog(msg.from.print_name.." PM", "Added "..msg.action.user.id.." to chat "..msg.to.print_name.." (ID:"..msg.to.id..")") - send_large_msg(receiver, "Added you to chat:\n\n"..group_name.." (ID:"..msg.to.id..")") - end - end]] + if matches[1] == 'chats'then + if is_admin(msg) and msg.to.type == 'chat' then + return chat_list(msg) + elseif msg.to.type ~= 'chat' then + return chat_list(msg) + end + end if matches[1] == 'chatlist'then if is_admin(msg) and msg.to.type == 'chat' then - chat_list(msg) + chat_list(msg) send_document("chat#id"..msg.from.id, "./groups/lists/listed_groups.txt", ok_cb, false) elseif msg.to.type ~= 'chat' then - chat_list(msg) + chat_list(msg) send_document("user#id"..msg.from.id, "./groups/lists/listed_groups.txt", ok_cb, false) end - end end - end end - +end return { patterns = { + "^[/!](chats)$", "^[/!](chatlist)$", "^[/!](join) (.*)$", "^[/!](kickme) (.*)$", @@ -95,3 +88,5 @@ return { }, run = run, } +end +