From 7e0c28f8d78e28f29f0446b32641a1900e573d08 Mon Sep 17 00:00:00 2001 From: MobinDehghani Date: Sat, 5 Nov 2016 12:17:38 -0700 Subject: [PATCH] Update supergroup.lua --- plugins/supergroup.lua | 2528 ---------------------------------------- 1 file changed, 2528 deletions(-) diff --git a/plugins/supergroup.lua b/plugins/supergroup.lua index 7994857..8b13789 100644 --- a/plugins/supergroup.lua +++ b/plugins/supergroup.lua @@ -1,2529 +1 @@ ---Begin supergrpup.lua for UB ---Check members #Add supergroup -local function check_member_super(cb_extra, success, result) - local receiver = cb_extra.receiver - local data = cb_extra.data - local msg = cb_extra.msg - if success == 0 then - send_large_msg(receiver, "Promote me to admin first!") - end - for k,v in pairs(result) do - local member_id = v.peer_id - if member_id ~= our_id then - -- SuperGroup configuration - data[tostring(msg.to.id)] = { - group_type = 'SuperGroup', - long_id = msg.to.peer_id, - moderators = {}, - set_owner = member_id , - settings = { - set_name = string.gsub(msg.to.title, '_', ' '), - lock_arabic = 'no', - lock_link = "no", - flood = 'yes', - lock_spam = 'yes', - lock_sticker = 'no', - member = 'no', - lock_fwd = 'no', - lock_tag = 'no', - lock_emoji = 'no', - lock_badword = 'no', - lock_hashtag = 'no', - lock_reply = 'no', - public = 'no', - lock_rtl = 'no', - lock_tgservice = 'no', - lock_contacts = 'no', - strict = 'no' - } - } - save_data(_config.moderation.data, data) - local groups = 'groups' - if not data[tostring(groups)] then - data[tostring(groups)] = {} - save_data(_config.moderation.data, data) - end - data[tostring(groups)][tostring(msg.to.id)] = msg.to.id - save_data(_config.moderation.data, data) - local text = "Group name : "..msg.to.title.."\nGroup has been Added by : @"..msg.from.username.." !" - return reply_msg(msg.id, text, ok_cb, false) - end - end -end ---Check Members #rem supergroup -local function check_member_superrem(cb_extra, success, result) - local receiver = cb_extra.receiver - local data = cb_extra.data - local msg = cb_extra.msg - for k,v in pairs(result) do - local member_id = v.id - if member_id ~= our_id then - -- Group configuration removal - data[tostring(msg.to.id)] = nil - save_data(_config.moderation.data, data) - local groups = 'groups' - if not data[tostring(groups)] then - data[tostring(groups)] = nil - save_data(_config.moderation.data, data) - end - data[tostring(groups)][tostring(msg.to.id)] = nil - save_data(_config.moderation.data, data) - local text = "Group name : "..msg.to.title.."\nGroup has been Removed by : @"..msg.from.username.." !" - return reply_msg(msg.id, text, ok_cb, false) - end - end -end - ---Function to Add supergroup -local function superadd(msg) - local data = load_data(_config.moderation.data) - local receiver = get_receiver(msg) - channel_get_users(receiver, check_member_super,{receiver = receiver, data = data, msg = msg}) -end - ---Function to remove supergroup -local function superrem(msg) - local data = load_data(_config.moderation.data) - local receiver = get_receiver(msg) - channel_get_users(receiver, check_member_superrem,{receiver = receiver, data = data, msg = msg}) -end - ---Get and output admins and bots in supergroup -local function callback(cb_extra, success, result) -local i = 1 -local chat_name = string.gsub(cb_extra.msg.to.print_name, "_", " ") -local member_type = cb_extra.member_type -local text = member_type.." for "..chat_name..":\n" -for k,v in pairsByKeys(result) do -if not v.first_name then - name = " " -else - vname = v.first_name:gsub("?", "") - name = vname:gsub("_", " ") - end - text = text.."\n"..i.." - "..name.."["..v.peer_id.."]" - i = i + 1 - end - send_large_msg(cb_extra.receiver, text) -end - - -local function check_member_super_deleted(cb_extra, success, result) -local receiver = cb_extra.receiver - local msg = cb_extra.msg - local deleted = 0 -if success == 0 then -send_large_msg(receiver, "first set me as admin!") -end -for k,v in pairs(result) do - if not v.first_name and not v.last_name then -deleted = deleted + 1 - kick_user(v.peer_id,msg.to.id) - end - end - send_large_msg(receiver, "Successfully Kicked all!\nNumber of Deleted Accounts kicked:"..deleted) - end - - -local function callback_clean_bots (extra, success, result) - local msg = extra.msg - local receiver = 'channel#id'..msg.to.id - local channel_id = msg.to.id - for k,v in pairs(result) do - local bot_id = v.peer_id - kick_user(bot_id,channel_id) - end -end -local function callback_clean_members (extra, success, result) - local msg = extra.msg - local receiver = 'channel#id'..msg.to.id - local channel_id = msg.to.id - for k,v in pairs(result) do - local users_id = v.peer_id - kick_user(users_id,channel_id) - end -end - - ---Get and output info about supergroup -local function callback_info(cb_extra, success, result) -local title ="Group name : ["..result.title.."]\n\n" -local admin_num = "Admins: "..result.admins_count.."\n" -local user_num = "Users: "..result.participants_count.."\n" -local kicked_num = "Kicked users : "..result.kicked_count.."\n" -local channel_id = "ID: "..result.peer_id.."\n" -local user_name = "Your Username : "..msg.from.username.."\n" -if result.username then - channel_username = "Username: @"..result.username -else - channel_username = "" -end -local text = title..admin_num..user_name..user_num..kicked_num..channel_id..channel_username - send_large_msg(cb_extra.receiver, text) -end - ---Get and output members of supergroup -local function callback_who(cb_extra, success, result) -local text = "Members for "..cb_extra.receiver -local i = 1 -for k,v in pairsByKeys(result) do -if not v.print_name then - name = " " -else - vname = v.print_name:gsub("?", "") - name = vname:gsub("_", " ") -end - if v.username then - username = " @"..v.username - else - username = "" - end - text = text.."\n"..i.." - "..name.." "..username.." [ "..v.peer_id.." ]\n" - --text = text.."\n"..username - i = i + 1 -end - local file = io.open("./groups/lists/supergroups/"..cb_extra.receiver..".txt", "w") - file:write(text) - file:flush() - file:close() - send_document(cb_extra.receiver,"./groups/lists/supergroups/"..cb_extra.receiver..".txt", ok_cb, false) - post_msg(cb_extra.receiver, text, ok_cb, false) -end - ---Get and output list of kicked users for supergroup -local function callback_kicked(cb_extra, success, result) ---vardump(result) -local text = "Kicked Members for SuperGroup "..cb_extra.receiver.."\n\n" -local i = 1 -for k,v in pairsByKeys(result) do -if not v.print_name then - name = " " -else - vname = v.print_name:gsub("?", "") - name = vname:gsub("_", " ") -end - if v.username then - name = name.." @"..v.username - end - text = text.."\n"..i.." - "..name.." [ "..v.peer_id.." ]\n" - i = i + 1 -end - local file = io.open("./groups/lists/supergroups/kicked/"..cb_extra.receiver..".txt", "w") - file:write(text) - file:flush() - file:close() - send_document(cb_extra.receiver,"./groups/lists/supergroups/kicked/"..cb_extra.receiver..".txt", ok_cb, false) - --send_large_msg(cb_extra.receiver, text) -end - ---Begin supergroup locks -local function lock_group_links(msg, data, target) - if not is_momod(msg) then - return - end - local group_link_lock = data[tostring(target)]['settings']['lock_link'] - if group_link_lock == 'yes' then - return 'Link posting is already locked' - else - data[tostring(target)]['settings']['lock_link'] = 'yes' - save_data(_config.moderation.data, data) - return 'Link Status switched to : lock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function unlock_group_links(msg, data, target) - if not is_momod(msg) then - return - end - local group_link_lock = data[tostring(target)]['settings']['lock_link'] - if group_link_lock == 'no' then - return 'Lock Link was on : unlock\nStatus not changed !' - else - data[tostring(target)]['settings']['lock_link'] = 'no' - save_data(_config.moderation.data, data) - return 'Link Status switched to : UnLock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function lock_group_spam(msg, data, target) - if not is_momod(msg) then - return - end - if not is_owner(msg) then - return "Owners only!" - end - local group_spam_lock = data[tostring(target)]['settings']['lock_spam'] - if group_spam_lock == 'yes' then - return 'SuperGroup spam is already locked' - else - data[tostring(target)]['settings']['lock_spam'] = 'yes' - save_data(_config.moderation.data, data) - return 'Spam Status switched to : lock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function unlock_group_spam(msg, data, target) - if not is_momod(msg) then - return - end - local group_spam_lock = data[tostring(target)]['settings']['lock_spam'] - if group_spam_lock == 'no' then - return 'Lock Spam[long msg] was on : unlock\nStatus not changed !' - else - data[tostring(target)]['settings']['lock_spam'] = 'no' - save_data(_config.moderation.data, data) - return 'Spam Status switched to : UnLock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - - -local function lock_group_emoji(msg, data, target) - if not is_momod(msg) then - return - end - if not is_owner(msg) then - return "Owners only!" - end - local group_emoji_lock = data[tostring(target)]['settings']['lock_emoji'] - if group_emoji_lock == 'yes' then - return 'SuperGroup Emoji is already locked' - else - data[tostring(target)]['settings']['lock_emoji'] = 'yes' - save_data(_config.moderation.data, data) - return 'Emoji Status switched to : lock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function unlock_group_emoji(msg, data, target) - if not is_momod(msg) then - return - end - local group_emoji_lock = data[tostring(target)]['settings']['lock_emoji'] - if group_emoji_lock == 'no' then - return 'Emoji Status was on : unlock\nStatus not changed !' - else - data[tostring(target)]['settings']['lock_emoji'] = 'no' - save_data(_config.moderation.data, data) - return 'Emoji Status switched to : UnLock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - - -local function lock_group_badword(msg, data, target) - if not is_momod(msg) then - return - end - if not is_owner(msg) then - return "Owners only!" - end - local group_badword_lock = data[tostring(target)]['settings']['lock_badword'] - if group_badword_lock == 'yes' then - return 'SuperGroup badword is already locked' - else - data[tostring(target)]['settings']['lock_badword'] = 'yes' - save_data(_config.moderation.data, data) - return 'badword Status switched to : lock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function unlock_group_badword(msg, data, target) - if not is_momod(msg) then - return - end - local group_badword_lock = data[tostring(target)]['settings']['lock_badword'] - if group_badword_lock == 'no' then - return 'badword Status was on : unlock\nStatus not changed !' - else - data[tostring(target)]['settings']['lock_badword'] = 'no' - save_data(_config.moderation.data, data) - return 'badword Status switched to : UnLock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function lock_group_flood(msg, data, target) - if not is_momod(msg) then - return - end - local group_flood_lock = data[tostring(target)]['settings']['flood'] - if group_flood_lock == 'yes' then - return 'Flood is already locked' - else - data[tostring(target)]['settings']['flood'] = 'yes' - save_data(_config.moderation.data, data) - return 'Flood Status switched to : lock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function unlock_group_flood(msg, data, target) - if not is_momod(msg) then - return - end - local group_flood_lock = data[tostring(target)]['settings']['flood'] - if group_flood_lock == 'no' then - return 'Lock flood was on : unlock\nStatus not changed !' - else - data[tostring(target)]['settings']['flood'] = 'no' - save_data(_config.moderation.data, data) - return 'Flood Status switched to : UnLock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function lock_group_arabic(msg, data, target) - if not is_momod(msg) then - return - end - local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic'] - if group_arabic_lock == 'yes' then - return 'Arabic is already locked' - else - data[tostring(target)]['settings']['lock_arabic'] = 'yes' - save_data(_config.moderation.data, data) - return 'Arabic Status switched to : lock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function unlock_group_arabic(msg, data, target) - if not is_momod(msg) then - return - end - local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic'] - if group_arabic_lock == 'no' then - return 'Lock Arabic was on : unlock\nStatus not changed !' - else - data[tostring(target)]['settings']['lock_arabic'] = 'no' - save_data(_config.moderation.data, data) - return 'Arabic Status switched to : UnLock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function lock_group_tag(msg, data, target) - if not is_momod(msg) then - return - end - local group_tag_lock = data[tostring(target)]['settings']['lock_tag'] - if group_tag_lock == 'yes' then - return 'tag is already locked' - else - data[tostring(target)]['settings']['lock_tag'] = 'yes' - save_data(_config.moderation.data, data) - return 'Tag[ @ ] Status switched to : lock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function unlock_group_tag(msg, data, target) - if not is_momod(msg) then - return - end - local group_tag_lock = data[tostring(target)]['settings']['lock_tag'] - if group_tag_lock == 'no' then - return 'Lock Tag[ @ ] was on : unlock\nStatus not changed !' - else - data[tostring(target)]['settings']['lock_tag'] = 'no' - save_data(_config.moderation.data, data) - return 'Tag Status switched to : UnLock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function lock_group_hashtag(msg, data, target) - if not is_momod(msg) then - return - end - local group_hashtag_lock = data[tostring(target)]['settings']['lock_hashtag'] - if group_hashtag_lock == 'yes' then - return 'hashtag is already locked' - else - data[tostring(target)]['settings']['lock_hashtag'] = 'yes' - save_data(_config.moderation.data, data) - return 'Hashtag[ # ] Status switched to : lock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function unlock_group_hashtag(msg, data, target) - if not is_momod(msg) then - return - end - local group_hashtag_lock = data[tostring(target)]['settings']['lock_hashtag'] - if group_hashtag_lock == 'no' then - return 'Lock HashTag[ # ] was on : unlock\nStatus not changed !' - else - data[tostring(target)]['settings']['lock_hashtag'] = 'no' - save_data(_config.moderation.data, data) - return 'Hashtag Status switched to : UnLock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - - -local function lock_group_fwd(msg, data, target) - if not is_momod(msg) then - return - end - local group_fwd_lock = data[tostring(target)]['settings']['lock_fwd'] - if group_fwd_lock == 'yes' then - return 'forward is already locked' - else - data[tostring(target)]['settings']['lock_fwd'] = 'yes' - save_data(_config.moderation.data, data) - return 'Forward Status switched to : lock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function unlock_group_fwd(msg, data, target) - if not is_momod(msg) then - return - end - local group_fwd_lock = data[tostring(target)]['settings']['lock_fwd'] - if group_fwd_lock == 'no' then - return 'Lock Forward was on : unlock\nStatus not changed !' - else - data[tostring(target)]['settings']['lock_fwd'] = 'no' - save_data(_config.moderation.data, data) - return 'Forward Status switched to : UnLock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function lock_group_membermod(msg, data, target) - if not is_momod(msg) then - return - end - local group_member_lock = data[tostring(target)]['settings']['lock_member'] - if group_member_lock == 'yes' then - return 'SuperGroup members are already locked' - else - data[tostring(target)]['settings']['lock_member'] = 'yes' - save_data(_config.moderation.data, data) - end - return 'Member Join Status switched to : lock\nChanged by : @'..(msg.from.username or msg.from.first_name) -end - -local function unlock_group_membermod(msg, data, target) - if not is_momod(msg) then - return - end - local group_member_lock = data[tostring(target)]['settings']['lock_member'] - if group_member_lock == 'no' then - return 'Lock Member join was on : unlock\nStatus not changed !' - else - data[tostring(target)]['settings']['lock_member'] = 'no' - save_data(_config.moderation.data, data) - return 'Join member Status switched to : UnLock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function lock_group_rtl(msg, data, target) - if not is_momod(msg) then - return - end - local group_rtl_lock = data[tostring(target)]['settings']['lock_rtl'] - if group_rtl_lock == 'yes' then - return 'RTL is already locked' - else - data[tostring(target)]['settings']['lock_rtl'] = 'yes' - save_data(_config.moderation.data, data) - return 'RTL[Right to left PM] Status switched to : lock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function unlock_group_rtl(msg, data, target) - if not is_momod(msg) then - return - end - local group_rtl_lock = data[tostring(target)]['settings']['lock_rtl'] - if group_rtl_lock == 'no' then - return 'Lock RTL[Right To left Mesages] was on : unlock\nStatus not changed !' - else - data[tostring(target)]['settings']['lock_rtl'] = 'no' - save_data(_config.moderation.data, data) - return 'RTL Status switched to : UnLock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function lock_group_tgservice(msg, data, target) - if not is_momod(msg) then - return - end - local group_tgservice_lock = data[tostring(target)]['settings']['lock_tgservice'] - if group_tgservice_lock == 'yes' then - return 'Tgservice is already locked' - else - data[tostring(target)]['settings']['lock_tgservice'] = 'yes' - save_data(_config.moderation.data, data) - return 'TGService[Join Group Pm] Status switched to : lock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function unlock_group_tgservice(msg, data, target) - if not is_momod(msg) then - return - end - local group_tgservice_lock = data[tostring(target)]['settings']['lock_tgservice'] - if group_tgservice_lock == 'no' then - return 'Lock TGservice[Join Group Pm] was on : unlock\nStatus not changed !' - else - data[tostring(target)]['settings']['lock_tgservice'] = 'no' - save_data(_config.moderation.data, data) - return 'TGService Status switched to : UnLock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function lock_group_sticker(msg, data, target) - if not is_momod(msg) then - return - end - local group_sticker_lock = data[tostring(target)]['settings']['lock_sticker'] - if group_sticker_lock == 'yes' then - return 'Sticker posting is already locked' - else - data[tostring(target)]['settings']['lock_sticker'] = 'yes' - save_data(_config.moderation.data, data) - return 'Sticker Status switched to : lock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function unlock_group_sticker(msg, data, target) - if not is_momod(msg) then - return - end - local group_sticker_lock = data[tostring(target)]['settings']['lock_sticker'] - if group_sticker_lock == 'no' then - return 'Lock Sticker was on : unlock\nStatus not changed !' - else - data[tostring(target)]['settings']['lock_sticker'] = 'no' - save_data(_config.moderation.data, data) - return 'Sticker Status switched to : UnLock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - - -local function lock_group_reply(msg, data, target) - if not is_momod(msg) then - return - end - local group_reply_lock = data[tostring(target)]['settings']['lock_reply'] - if group_reply_lock == 'yes' then - return 'reply is already locked' - else - data[tostring(target)]['settings']['lock_reply'] = 'yes' - save_data(_config.moderation.data, data) - return 'Reply Status switched to : lock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function unlock_group_reply(msg, data, target) - if not is_momod(msg) then - return - end - local group_reply_lock = data[tostring(target)]['settings']['lock_reply'] - if group_reply_lock == 'no' then - return 'Lock Reply was on : unlock\nStatus not changed !' - else - data[tostring(target)]['settings']['lock_reply'] = 'no' - save_data(_config.moderation.data, data) - return 'Share Contact Status switched to : UnLock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function lock_group_contacts(msg, data, target) - if not is_momod(msg) then - return - end - local group_contacts_lock = data[tostring(target)]['settings']['lock_contacts'] - if group_contacts_lock == 'yes' then - return 'Contact posting is already locked' - else - data[tostring(target)]['settings']['lock_contacts'] = 'yes' - save_data(_config.moderation.data, data) - return 'Share Contact Status switched to : lock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function unlock_group_contacts(msg, data, target) - if not is_momod(msg) then - return - end - local group_contacts_lock = data[tostring(target)]['settings']['lock_contacts'] - if group_contacts_lock == 'no' then - return 'Lock Contacts was on : unlock\nStatus not changed !' - else - data[tostring(target)]['settings']['lock_contacts'] = 'no' - save_data(_config.moderation.data, data) - return 'Contacts Status switched to : UnLock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function enable_strict_rules(msg, data, target) - if not is_momod(msg) then - return - end - local group_strict_lock = data[tostring(target)]['settings']['strict'] - if group_strict_lock == 'yes' then - return 'Settings are already strictly enforced' - else - data[tostring(target)]['settings']['strict'] = 'yes' - save_data(_config.moderation.data, data) - return 'Stricting Settings Status switched to : lock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end - -local function disable_strict_rules(msg, data, target) - if not is_momod(msg) then - return - end - local group_strict_lock = data[tostring(target)]['settings']['strict'] - if group_strict_lock == 'no' then - return 'Stricting Settings was on : unlock\nStatus not changed !' - else - data[tostring(target)]['settings']['strict'] = 'no' - save_data(_config.moderation.data, data) - return 'Stricting Settings Status switched to : UnLock\nChanged by : @'..(msg.from.username or msg.from.first_name) - end -end ---End supergroup locks - ---'Set supergroup rules' function -local function set_rulesmod(msg, data, target) - if not is_momod(msg) then - return - end - local data_cat = 'rules' - data[tostring(target)][data_cat] = rules - save_data(_config.moderation.data, data) - return 'SuperGroup rules set' -end - ---'Get supergroup rules' function -local function get_rules(msg, data) - local data_cat = 'rules' - if not data[tostring(msg.to.id)][data_cat] then - return 'No rules available.' - end - local rules = data[tostring(msg.to.id)][data_cat] - local group_name = data[tostring(msg.to.id)]['settings']['set_name'] - local rules = group_name..' rules:\n\n'..rules:gsub("/n", " ") - return rules -end - ---Set supergroup to public or not public function -local function set_public_membermod(msg, data, target) - if not is_momod(msg) then - return "For moderators only!" - end - local group_public_lock = data[tostring(target)]['settings']['public'] - local long_id = data[tostring(target)]['long_id'] - if not long_id then - data[tostring(target)]['long_id'] = msg.to.peer_id - save_data(_config.moderation.data, data) - end - if group_public_lock == 'yes' then - return 'Group is already public' - else - data[tostring(target)]['settings']['public'] = 'yes' - save_data(_config.moderation.data, data) - end - return 'SuperGroup is now: public' -end - -local function unset_public_membermod(msg, data, target) - if not is_momod(msg) then - return - end - local group_public_lock = data[tostring(target)]['settings']['public'] - local long_id = data[tostring(target)]['long_id'] - if not long_id then - data[tostring(target)]['long_id'] = msg.to.peer_id - save_data(_config.moderation.data, data) - end - if group_public_lock == 'no' then - return 'Group is not public' - else - data[tostring(target)]['settings']['public'] = 'no' - data[tostring(target)]['long_id'] = msg.to.long_id - save_data(_config.moderation.data, data) - return 'SuperGroup is now: not public' - end -end - ---Show supergroup settings; function -function show_supergroup_settingsmod(msg, target) - if not is_momod(msg) then - return - end - local data = load_data(_config.moderation.data) - if data[tostring(target)] then - if data[tostring(target)]['settings']['flood_msg_max'] then - NUM_MSG_MAX = tonumber(data[tostring(target)]['settings']['flood_msg_max']) - print('custom'..NUM_MSG_MAX) - else - NUM_MSG_MAX = 5 - end - end - if data[tostring(target)]['settings'] then - if not data[tostring(target)]['settings']['public'] then - data[tostring(target)]['settings']['public'] = 'no' - end - end - if data[tostring(target)]['settings'] then - if not data[tostring(target)]['settings']['lock_fwd'] then - data[tostring(target)]['settings']['lock_fwd'] = 'no' - end - end - if data[tostring(target)]['settings'] then - if not data[tostring(target)]['settings']['lock_tag'] then - data[tostring(target)]['settings']['lock_tag'] = 'no' - end - end - if data[tostring(target)]['settings'] then - if not data[tostring(target)]['settings']['lock_hashtag'] then - data[tostring(target)]['settings']['lock_hashtag'] = 'no' - end - end - if data[tostring(target)]['settings'] then - if not data[tostring(target)]['settings']['lock_rtl'] then - data[tostring(target)]['settings']['lock_rtl'] = 'no' - end - end - if data[tostring(target)]['settings'] then - if not data[tostring(target)]['settings']['lock_tgservice'] then - data[tostring(target)]['settings']['lock_tgservice'] = 'no' - end - end - if data[tostring(target)]['settings'] then - if not data[tostring(target)]['settings']['lock_contacts'] then - data[tostring(target)]['settings']['lock_contacts'] = 'no' - end - end - if data[tostring(target)]['settings'] then - if not data[tostring(target)]['settings']['lock_badword'] then - data[tostring(target)]['settings']['lock_badword'] = 'no' - end - end - if data[tostring(target)]['settings'] then - if not data[tostring(target)]['settings']['lock_emoji'] then - data[tostring(target)]['settings']['lock_emoji'] = 'no' - end - end - if data[tostring(target)]['settings'] then - if not data[tostring(target)]['settings']['lock_reply'] then - data[tostring(target)]['settings']['lock_reply'] = 'no' - end - end - if data[tostring(target)]['settings'] then - if not data[tostring(target)]['settings']['lock_member'] then - data[tostring(target)]['settings']['lock_member'] = 'no' - end - end - local settings = data[tostring(target)]['settings'] - local text = "Group Settings :\n" - .."Lock Reply : "..settings.lock_reply.."\n" - .."Lock Contact share : "..settings.lock_contacts.."\n" - .."Lock links : "..settings.lock_link.."\n" - .."Lock Forward : "..settings.lock_fwd.."\n" -.."Lock #hashtag : "..settings.lock_hashtag.."\n" -.."Lock tag : "..settings.lock_tag.."\n" -.."Lock sticker : "..settings.lock_sticker.."\n" -.."Lock flood : "..settings.flood.."\n" -.."Lock spam : "..settings.lock_spam.."\n" -.."Lock Badwords : "..settings.lock_badword.."\n" -.."Lock Emoji : "..settings.lock_emoji.."\n" -.."Lock Arabic : "..settings.lock_arabic.."\n\n" -.."Additional Settings :\n" -.."Lock Member : "..settings.lock_member.."\n" -.."Lock RTL : "..settings.lock_rtl.."\n" -.."Lock Tgservice : "..settings.lock_tgservice.."\n" -.."Flood number : "..NUM_MSG_MAX.."\n" -.."Public SuperGroup: "..settings.public.."\n" -.."Group type : SuperGroup\n" -.."Bot Version : 2.0\n" -.."Channel : @IR_TEAM\n" -.."Strict settings: "..settings.strict.."\n\n" -.."Requester Information :\n" -.."Name : "..msg.from.first_name.." "..(msg.from.last_name or '').."\n" -.."Your Username : @"..(msg.from.username or '') - return text - end - -local function promote_admin(receiver, member_username, user_id) - local data = load_data(_config.moderation.data) - local group = string.gsub(receiver, 'channel#id', '') - local member_tag_username = string.gsub(member_username, '@', '(at)') - if not data[group] then - return - end - if data[group]['moderators'][tostring(user_id)] then - return send_large_msg(receiver, member_username..' is already a moderator.') - end - data[group]['moderators'][tostring(user_id)] = member_tag_username - save_data(_config.moderation.data, data) -end - -local function demote_admin(receiver, member_username, user_id) - local data = load_data(_config.moderation.data) - local group = string.gsub(receiver, 'channel#id', '') - if not data[group] then - return - end - if not data[group]['moderators'][tostring(user_id)] then - return send_large_msg(receiver, member_tag_username..' is not a moderator.') - end - data[group]['moderators'][tostring(user_id)] = nil - save_data(_config.moderation.data, data) -end - -local function promote2(receiver, member_username, user_id) - local data = load_data(_config.moderation.data) - local group = string.gsub(receiver, 'channel#id', '') - local member_tag_username = string.gsub(member_username, '@', '(at)') - if not data[group] then - return send_large_msg(receiver, 'SuperGroup is not added.') - end - if data[group]['moderators'][tostring(user_id)] then - return send_large_msg(receiver, member_username..' is already a moderator.') - end - data[group]['moderators'][tostring(user_id)] = member_tag_username - save_data(_config.moderation.data, data) - send_large_msg(receiver, member_username..' has been promoted.') -end - -local function demote2(receiver, member_username, user_id) - local data = load_data(_config.moderation.data) - local group = string.gsub(receiver, 'channel#id', '') - if not data[group] then - return send_large_msg(receiver, 'Group is not added.') - end - if not data[group]['moderators'][tostring(user_id)] then - return send_large_msg(receiver, member_tag_username..' is not a moderator.') - end - data[group]['moderators'][tostring(user_id)] = nil - save_data(_config.moderation.data, data) - send_large_msg(receiver, member_username..' has been demoted.') -end - -local function modlist(msg) - local data = load_data(_config.moderation.data) - local groups = "groups" - if not data[tostring(groups)][tostring(msg.to.id)] then - return 'SuperGroup is not added.' - end - -- determine if table is empty - if next(data[tostring(msg.to.id)]['moderators']) == nil then - return 'No moderator in this group.' - end - local i = 1 - local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n' - for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do - message = message ..i..' - '..v..' [' ..k.. '] \n' - i = i + 1 - end - return message -end - --- Start by reply actions -function get_message_callback(extra, success, result) - local get_cmd = extra.get_cmd - local msg = extra.msg - local data = load_data(_config.moderation.data) - local print_name = user_print_name(msg.from):gsub("?", "") - local name_log = print_name:gsub("_", " ") - if get_cmd == "id" and not result.action then - local channel = 'channel#id'..result.to.peer_id - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] obtained id for: ["..result.from.peer_id.."]") - id1 = send_large_msg(channel, result.from.peer_id) - elseif get_cmd == 'id' and result.action then - local action = result.action.type - if action == 'chat_add_user' or action == 'chat_del_user' or action == 'chat_rename' or action == 'chat_change_photo' then - if result.action.user then - user_id = result.action.user.peer_id - else - user_id = result.peer_id - end - local channel = 'channel#id'..result.to.peer_id - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] obtained id by service msg for: ["..user_id.."]") - id1 = send_large_msg(channel, user_id) - end - elseif get_cmd == "idfrom" then - local channel = 'channel#id'..result.to.peer_id - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] obtained id for msg fwd from: ["..result.fwd_from.peer_id.."]") - id2 = send_large_msg(channel, result.fwd_from.peer_id) - elseif get_cmd == 'channel_block' and not result.action then - local member_id = result.from.peer_id - local channel_id = result.to.peer_id - if member_id == msg.from.id then - return send_large_msg("channel#id"..channel_id, "Leave using kickme command") - end - if is_momod2(member_id, channel_id) and not is_admin2(msg.from.id) then - return send_large_msg("channel#id"..channel_id, "You can't kick mods/owner/admins") - end - if is_admin2(member_id) then - return send_large_msg("channel#id"..channel_id, "You can't kick other admins") - end - ----savelog(msg.to.id, name_log.." ["..msg.from.id.."] kicked: ["..user_id.."] by reply") - kick_user(member_id, channel_id) - elseif get_cmd == 'channel_block' and result.action and result.action.type == 'chat_add_user' then - local user_id = result.action.user.peer_id - local channel_id = result.to.peer_id - if member_id == msg.from.id then - return send_large_msg("channel#id"..channel_id, "Leave using kickme command") - end - if is_momod2(member_id, channel_id) and not is_admin2(msg.from.id) then - return send_large_msg("channel#id"..channel_id, "You can't kick mods/owner/admins") - end - if is_admin2(member_id) then - return send_large_msg("channel#id"..channel_id, "You can't kick other admins") - end - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] kicked: ["..user_id.."] by reply to sev. msg.") - kick_user(user_id, channel_id) - elseif get_cmd == "del" then - delete_msg(result.id, ok_cb, false) - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted a message by reply") - elseif get_cmd == "setadmin" then - local user_id = result.from.peer_id - local channel_id = "channel#id"..result.to.peer_id - channel_set_admin(channel_id, "user#id"..user_id, ok_cb, false) - if result.from.username then - text = "@"..result.from.username.." set as an admin" - else - text = "[ "..user_id.." ]set as an admin" - end - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set: ["..user_id.."] as admin by reply") - send_large_msg(channel_id, text) - elseif get_cmd == "demoteadmin" then - local user_id = result.from.peer_id - local channel_id = "channel#id"..result.to.peer_id - if is_admin2(result.from.peer_id) then - return send_large_msg(channel_id, "You can't demote global admins!") - end - channel_demote(channel_id, "user#id"..user_id, ok_cb, false) - if result.from.username then - text = "@"..result.from.username.." has been demoted from admin" - else - text = "[ "..user_id.." ] has been demoted from admin" - end - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted: ["..user_id.."] from admin by reply") - send_large_msg(channel_id, text) - elseif get_cmd == "setowner" then - local group_owner = data[tostring(result.to.peer_id)]['set_owner'] - if group_owner then - local channel_id = 'channel#id'..result.to.peer_id - if not is_admin2(tonumber(group_owner)) and not is_support(tonumber(group_owner)) then - local user = "user#id"..group_owner - channel_demote(channel_id, user, ok_cb, false) - end - local user_id = "user#id"..result.from.peer_id - channel_set_admin(channel_id, user_id, ok_cb, false) - data[tostring(result.to.peer_id)]['set_owner'] = tostring(result.from.peer_id) - save_data(_config.moderation.data, data) - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set: ["..result.from.peer_id.."] as owner by reply") - if result.from.username then - text = "@"..result.from.username.." [ "..result.from.peer_id.." ] added as owner" - else - text = "[ "..result.from.peer_id.." ] added as owner" - end - send_large_msg(channel_id, text) - end - elseif get_cmd == "promote" then - local receiver = result.to.peer_id - local full_name = (result.from.first_name or '')..' '..(result.from.last_name or '') - local member_name = full_name:gsub("?", "") - local member_username = member_name:gsub("_", " ") - if result.from.username then - member_username = '@'.. result.from.username - end - local member_id = result.from.peer_id - if result.to.peer_type == 'channel' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted mod: @"..member_username.."["..result.from.peer_id.."] by reply") - promote2("channel#id"..result.to.peer_id, member_username, member_id) - --channel_set_mod(channel_id, user, ok_cb, false) - end - elseif get_cmd == "demote" then - local full_name = (result.from.first_name or '')..' '..(result.from.last_name or '') - local member_name = full_name:gsub("?", "") - local member_username = member_name:gsub("_", " ") - if result.from.username then - member_username = '@'.. result.from.username - end - local member_id = result.from.peer_id - --local user = "user#id"..result.peer_id - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted mod: @"..member_username.."["..user_id.."] by reply") - demote2("channel#id"..result.to.peer_id, member_username, member_id) - --channel_demote(channel_id, user, ok_cb, false) - elseif get_cmd == 'mute_user' then - if result.service then - local action = result.action.type - if action == 'chat_add_user' or action == 'chat_del_user' or action == 'chat_rename' or action == 'chat_change_photo' then - if result.action.user then - user_id = result.action.user.peer_id - end - end - if action == 'chat_add_user_link' then - if result.from then - user_id = result.from.peer_id - end - end - else - user_id = result.from.peer_id - end - local receiver = extra.receiver - local chat_id = msg.to.id - print(user_id) - print(chat_id) - if is_muted_user(chat_id, user_id) then - unmute_user(chat_id, user_id) - send_large_msg(receiver, "["..user_id.."] removed from the muted user list") - elseif is_admin1(msg) then - mute_user(chat_id, user_id) - send_large_msg(receiver, " ["..user_id.."] added to the muted user list") - end - end -end --- End by reply actions - ---By ID actions -local function cb_user_info(extra, success, result) - local receiver = extra.receiver - local user_id = result.peer_id - local get_cmd = extra.get_cmd - local data = load_data(_config.moderation.data) - --[[if get_cmd == "setadmin" then - local user_id = "user#id"..result.peer_id - channel_set_admin(receiver, user_id, ok_cb, false) - if result.username then - text = "@"..result.username.." has been set as an admin" - else - text = "[ "..result.peer_id.." ] has been set as an admin" - end - send_large_msg(receiver, text)]] - if get_cmd == "demoteadmin" then - if is_admin2(result.peer_id) then - return send_large_msg(receiver, "You can't demote global admins!") - end - local user_id = "user#id"..result.peer_id - channel_demote(receiver, user_id, ok_cb, false) - if result.username then - text = "@"..result.username.." has been demoted from admin" - send_large_msg(receiver, text) - else - text = "[ "..result.peer_id.." ] has been demoted from admin" - send_large_msg(receiver, text) - end - elseif get_cmd == "promote" then - if result.username then - member_username = "@"..result.username - else - member_username = string.gsub(result.print_name, '_', ' ') - end - promote2(receiver, member_username, user_id) - elseif get_cmd == "demote" then - if result.username then - member_username = "@"..result.username - else - member_username = string.gsub(result.print_name, '_', ' ') - end - demote2(receiver, member_username, user_id) - end -end - --- Begin resolve username actions -local function callbackres(extra, success, result) - local member_id = result.peer_id - local member_username = "@"..result.username - local get_cmd = extra.get_cmd - if get_cmd == "res" then - local user = result.peer_id - local name = string.gsub(result.print_name, "_", " ") - local channel = 'channel#id'..extra.channelid - send_large_msg(channel, user..'\n'..name) - return user - elseif get_cmd == "id" then - local user = result.peer_id - local channel = 'channel#id'..extra.channelid - send_large_msg(channel, user) - return user - elseif get_cmd == "invite" then - local receiver = extra.channel - local user_id = "user#id"..result.peer_id - channel_invite(receiver, user_id, ok_cb, false) - --[[elseif get_cmd == "channel_block" then - local user_id = result.peer_id - local channel_id = extra.channelid - local sender = extra.sender - if member_id == sender then - return send_large_msg("channel#id"..channel_id, "Leave using kickme command") - end - if is_momod2(member_id, channel_id) and not is_admin2(sender) then - return send_large_msg("channel#id"..channel_id, "You can't kick mods/owner/admins") - end - if is_admin2(member_id) then - return send_large_msg("channel#id"..channel_id, "You can't kick other admins") - end - kick_user(user_id, channel_id) - elseif get_cmd == "setadmin" then - local user_id = "user#id"..result.peer_id - local channel_id = extra.channel - channel_set_admin(channel_id, user_id, ok_cb, false) - if result.username then - text = "@"..result.username.." has been set as an admin" - send_large_msg(channel_id, text) - else - text = "@"..result.peer_id.." has been set as an admin" - send_large_msg(channel_id, text) - end - elseif get_cmd == "setowner" then - local receiver = extra.channel - local channel = string.gsub(receiver, 'channel#id', '') - local from_id = extra.from_id - local group_owner = data[tostring(channel)]['set_owner'] - if group_owner then - local user = "user#id"..group_owner - if not is_admin2(group_owner) and not is_support(group_owner) then - channel_demote(receiver, user, ok_cb, false) - end - local user_id = "user#id"..result.peer_id - channel_set_admin(receiver, user_id, ok_cb, false) - data[tostring(channel)]['set_owner'] = tostring(result.peer_id) - save_data(_config.moderation.data, data) - --savelog(channel, name_log.." ["..from_id.."] set ["..result.peer_id.."] as owner by username") - if result.username then - text = member_username.." [ "..result.peer_id.." ] added as owner" - else - text = "[ "..result.peer_id.." ] added as owner" - end - send_large_msg(receiver, text) - end]] - elseif get_cmd == "promote" then - local receiver = extra.channel - local user_id = result.peer_id - --local user = "user#id"..result.peer_id - promote2(receiver, member_username, user_id) - --channel_set_mod(receiver, user, ok_cb, false) - elseif get_cmd == "demote" then - local receiver = extra.channel - local user_id = result.peer_id - local user = "user#id"..result.peer_id - demote2(receiver, member_username, user_id) - elseif get_cmd == "demoteadmin" then - local user_id = "user#id"..result.peer_id - local channel_id = extra.channel - if is_admin2(result.peer_id) then - return send_large_msg(channel_id, "You can't demote global admins!") - end - channel_demote(channel_id, user_id, ok_cb, false) - if result.username then - text = "@"..result.username.." has been demoted from admin" - send_large_msg(channel_id, text) - else - text = "@"..result.peer_id.." has been demoted from admin" - send_large_msg(channel_id, text) - end - local receiver = extra.channel - local user_id = result.peer_id - demote_admin(receiver, member_username, user_id) - elseif get_cmd == 'mute_user' then - local user_id = result.peer_id - local receiver = extra.receiver - local chat_id = string.gsub(receiver, 'channel#id', '') - if is_muted_user(chat_id, user_id) then - unmute_user(chat_id, user_id) - send_large_msg(receiver, " ["..user_id.."] removed from muted user list") - elseif is_owner(extra.msg) then - mute_user(chat_id, user_id) - send_large_msg(receiver, " ["..user_id.."] added to muted user list") - end - end -end ---End resolve username actions - ---Begin non-channel_invite username actions -local function in_channel_cb(cb_extra, success, result) - local get_cmd = cb_extra.get_cmd - local receiver = cb_extra.receiver - local msg = cb_extra.msg - local data = load_data(_config.moderation.data) - local print_name = user_print_name(cb_extra.msg.from):gsub("?", "") - local name_log = print_name:gsub("_", " ") - local member = cb_extra.username - local memberid = cb_extra.user_id - if member then - text = 'No user @'..member..' in this SuperGroup.' - else - text = 'No user ['..memberid..'] in this SuperGroup.' - end -if get_cmd == "channel_block" then - for k,v in pairs(result) do - vusername = v.username - vpeer_id = tostring(v.peer_id) - if vusername == member or vpeer_id == memberid then - local user_id = v.peer_id - local channel_id = cb_extra.msg.to.id - local sender = cb_extra.msg.from.id - if user_id == sender then - return send_large_msg("channel#id"..channel_id, "Leave using kickme command") - end - if is_momod2(user_id, channel_id) and not is_admin2(sender) then - return send_large_msg("channel#id"..channel_id, "You can't kick mods/owner/admins") - end - if is_admin2(user_id) then - return send_large_msg("channel#id"..channel_id, "You can't kick other admins") - end - if v.username then - text = "" - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] kicked: @"..v.username.." ["..v.peer_id.."]") - else - text = "" - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] kicked: ["..v.peer_id.."]") - end - kick_user(user_id, channel_id) - return - end - end -elseif get_cmd == "setadmin" then - for k,v in pairs(result) do - vusername = v.username - vpeer_id = tostring(v.peer_id) - if vusername == member or vpeer_id == memberid then - local user_id = "user#id"..v.peer_id - local channel_id = "channel#id"..cb_extra.msg.to.id - channel_set_admin(channel_id, user_id, ok_cb, false) - if v.username then - text = "@"..v.username.." ["..v.peer_id.."] has been set as an admin" - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set admin @"..v.username.." ["..v.peer_id.."]") - else - text = "["..v.peer_id.."] has been set as an admin" - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set admin "..v.peer_id) - end - if v.username then - member_username = "@"..v.username - else - member_username = string.gsub(v.print_name, '_', ' ') - end - local receiver = channel_id - local user_id = v.peer_id - promote_admin(receiver, member_username, user_id) - - end - send_large_msg(channel_id, text) - return - end - elseif get_cmd == 'setowner' then - for k,v in pairs(result) do - vusername = v.username - vpeer_id = tostring(v.peer_id) - if vusername == member or vpeer_id == memberid then - local channel = string.gsub(receiver, 'channel#id', '') - local from_id = cb_extra.msg.from.id - local group_owner = data[tostring(channel)]['set_owner'] - if group_owner then - if not is_admin2(tonumber(group_owner)) and not is_support(tonumber(group_owner)) then - local user = "user#id"..group_owner - channel_demote(receiver, user, ok_cb, false) - end - local user_id = "user#id"..v.peer_id - channel_set_admin(receiver, user_id, ok_cb, false) - data[tostring(channel)]['set_owner'] = tostring(v.peer_id) - save_data(_config.moderation.data, data) - --savelog(channel, name_log.."["..from_id.."] set ["..v.peer_id.."] as owner by username") - if result.username then - text = member_username.." ["..v.peer_id.."] added as owner" - else - text = "["..v.peer_id.."] added as owner" - end - end - elseif memberid and vusername ~= member and vpeer_id ~= memberid then - local channel = string.gsub(receiver, 'channel#id', '') - local from_id = cb_extra.msg.from.id - local group_owner = data[tostring(channel)]['set_owner'] - if group_owner then - if not is_admin2(tonumber(group_owner)) and not is_support(tonumber(group_owner)) then - local user = "user#id"..group_owner - channel_demote(receiver, user, ok_cb, false) - end - data[tostring(channel)]['set_owner'] = tostring(memberid) - save_data(_config.moderation.data, data) - --savelog(channel, name_log.."["..from_id.."] set ["..memberid.."] as owner by username") - text = "["..memberid.."] added as owner" - end - end - end - end -send_large_msg(receiver, text) -end ---End non-channel_invite username actions - ---'Set supergroup photo' function -local function set_supergroup_photo(msg, success, result) - local data = load_data(_config.moderation.data) - if not data[tostring(msg.to.id)] then - return - end - local receiver = get_receiver(msg) - if success then - local file = 'data/photos/channel_photo_'..msg.to.id..'.jpg' - print('File downloaded to:', result) - os.rename(result, file) - print('File moved to:', file) - channel_set_photo(receiver, file, ok_cb, false) - data[tostring(msg.to.id)]['settings']['set_photo'] = file - save_data(_config.moderation.data, data) - send_large_msg(receiver, 'Photo saved!', ok_cb, false) - else - print('Error downloading: '..msg.id) - send_large_msg(receiver, 'Failed, please try again!', ok_cb, false) - end -end - ---Run function -local function run(msg, matches) - -local bot_id = 214035529 -local rlm = 1051763059 - -if matches[1]:lower() == 'join' and matches[2] and is_admin(msg) then - channel_invite('channel#id'..matches[2], 'user#id'..msg.from.id, ok_cb, false) - end -if matches[1]:lower() == 'leave' and matches[2] and is_sudo(msg) then - leave_channel('channel#id'..matches[2], ok_cb, false) - apileavechat(msg, '-100'..matches[2]) - return 'Done\nI Exited the Group : '..matches[2] - elseif matches[1]:lower() == 'leave' and not matches[2] and is_admin(msg) then - leave_channel('channel#id'..msg.to.id, ok_cb, false) - apileavechat(msg, '-100'..msg.to.id) - end - -if matches[1]:lower() == 'setexpire' then - if not is_sudo(msg) then return end - local time = os.time() - local buytime = tonumber(os.time()) - local timeexpire = tonumber(buytime) + (tonumber(matches[2]) * 86400) - redis:hset('expiretime',get_receiver(msg),timeexpire) - return reply_msg(msg.id, "Group charged for "..matches[2].." Days", ok_cb, false) - end - if matches[1]:lower() == 'expire' then - local expiretime = redis:hget ('expiretime', get_receiver(msg)) - if not expiretime then return 'Unlimited' else - local now = tonumber(os.time()) - return (math.floor((tonumber(expiretime) - tonumber(now)) / 86400) + 1) .. " Days" - end - end - - if matches[1]:lower() == '1m' and matches[2] then - if not is_sudo(msg) then return end - local time = os.time() - local buytime = tonumber(os.time()) - local timeexpire = tonumber(buytime) + (tonumber(1 * 30) * 86400) - redis:hset('expiretime','channel#id'..matches[2],timeexpire) - send_large_msg('channel#id'..matches[2], 'Group charged For 30 Days', ok_cb, false) - return reply_msg(msg.id, 'Done', ok_cb, false) - end - - if matches[1]:lower() == '3m' and matches[2] then - if not is_sudo(msg) then return end - local time = os.time() - local buytime = tonumber(os.time()) - local timeexpire = tonumber(buytime) + (tonumber(3 * 30) * 86400) - redis:hset('expiretime','channel#id'..matches[2],timeexpire) - send_large_msg('channel#id'..matches[2], 'Group charged For 90 Days', ok_cb, false) - return reply_msg(msg.id, 'Done', ok_cb, false) - end - if matches[1]:lower() == 'unlimite' and matches[2] then - if not is_sudo(msg) then return end - local time = os.time() - local buytime = tonumber(os.time()) - local timeexpire = tonumber(buytime) + (tonumber(2 * 99999999999) * 86400) - redis:hset('expiretime','channel#id'..matches[2],timeexpire) - send_large_msg('channel#id'..matches[2], 'Group charged For unlimited', ok_cb, false) - return reply_msg(msg.id, 'Done', ok_cb, false) - end - - - if msg.to.type == 'chat' then - if matches[1] == 'tosuper' then - if not is_admin1(msg) then - return - end - local receiver = get_receiver(msg) - chat_upgrade(receiver, ok_cb, false) - end - elseif msg.to.type == 'channel'then - if matches[1] == 'tosuper' then - if not is_admin1(msg) then - return - end - return "Already a SuperGroup" - end - end - if msg.to.type == 'channel' then - local support_id = msg.from.id - local receiver = get_receiver(msg) - local print_name = user_print_name(msg.from):gsub("?", "") - local name_log = print_name:gsub("_", " ") - local data = load_data(_config.moderation.data) - local creed = "channel#id"..1051763059 - local text_rem = 'New Group Removed !!!! :\nGp Info :\nGp ID : '..msg.to.id..'\nGp name : '..msg.to.title..'\nRemover Info\nUser ID : '..msg.from.id..'\nUsername : '..(msg.from.username or '')..'\nYou can leave the bot by /leave'..msg.to.id..' Command\nYou can join it by : /join'..msg.to.id..' command\nTo charge it for one month use : /1m'..msg.to.id..'Done !' - local text_add = 'New Group Added :\nGp Info :\nGp ID : '..msg.to.id..'\nGp name : '..msg.to.title..'\nAdder Info\nUser ID : '..msg.from.id..'\nUsername : '..(msg.from.username or '')..'\nYou can leave the bot by /leave'..msg.to.id..' Command\nYou can join it by : /join'..msg.to.id..' command\nTo charge it for one month use : /1m'..msg.to.id..'\nDone !' - if matches[1] == 'add' and not matches[2] then - if not is_admin1(msg) and not is_support(support_id) then - return - end - if is_super_group(msg) then - return reply_msg(msg.id, 'SuperGroup is already added.', ok_cb, false) - end - print("SuperGroup "..msg.to.print_name.."("..msg.to.id..") added") - send_msg(creed, text_add, ok_cb, false) - superadd(msg) - set_mutes(msg.to.id) - channel_set_admin(receiver, 'user#id'..msg.from.id, ok_cb, false) - end - - if matches[1] == 'rem' and is_admin1(msg) and not matches[2] then - if not is_super_group(msg) then - return reply_msg(msg.id, 'SuperGroup is not added.', ok_cb, false) - end - print("SuperGroup "..msg.to.print_name.."("..msg.to.id..") removed") - superrem(msg) - send_msg(creed, text_rem, ok_cb, false) - rem_mutes(msg.to.id) - end - - if not data[tostring(msg.to.id)] then - return - end - if matches[1] == "gpinfo" then - if not is_owner(msg) then - return - end - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup info") - channel_info(receiver, callback_info, {receiver = receiver, msg = msg}) - end - - if matches[1] == "admins" then - if not is_owner(msg) and not is_support(msg.from.id) then - return - end - member_type = 'Admins' - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup Admins list") - admins = channel_get_admins(receiver,callback, {receiver = receiver, msg = msg, member_type = member_type}) - end - - if matches[1] == "owner" then - local group_owner = data[tostring(msg.to.id)]['set_owner'] - if not group_owner then - return "no owner,ask admins in support groups to set owner for your SuperGroup" - end - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] used /owner") - return "SuperGroup owner is ["..group_owner..']' - end - - if matches[1] == "modlist" then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group modlist") - return modlist(msg) - -- channel_get_admins(receiver,callback, {receiver = receiver}) - end - - if matches[1] == "bots" and is_momod(msg) then - member_type = 'Bots' - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup bots list") - channel_get_bots(receiver, callback, {receiver = receiver, msg = msg, member_type = member_type}) - end - - if matches[1] == "who" and not matches[2] and is_momod(msg) then - local user_id = msg.from.peer_id - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup users list") - channel_get_users(receiver, callback_who, {receiver = receiver}) - end - - if matches[1] == "kicked" and is_momod(msg) then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested Kicked users list") - channel_get_kicked(receiver, callback_kicked, {receiver = receiver}) - end - - if matches[1] == 'del' and is_momod(msg) then - if type(msg.reply_id) ~= "nil" then - local cbreply_extra = { - get_cmd = 'del', - msg = msg - } - delete_msg(msg.id, ok_cb, false) - get_message(msg.reply_id, get_message_callback, cbreply_extra) - end - end - - if matches[1] == 'block' and is_momod(msg) then - if type(msg.reply_id) ~= "nil" then - local cbreply_extra = { - get_cmd = 'channel_block', - msg = msg - } - get_message(msg.reply_id, get_message_callback, cbreply_extra) - elseif matches[1] == 'block' and matches[2] and string.match(matches[2], '^%d+$') then - --[[local user_id = matches[2] - local channel_id = msg.to.id - if is_momod2(user_id, channel_id) and not is_admin2(user_id) then - return send_large_msg(receiver, "You can't kick mods/owner/admins") - end - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] kicked: [ user#id"..user_id.." ]") - kick_user(user_id, channel_id)]] - local get_cmd = 'channel_block' - local msg = msg - local user_id = matches[2] - channel_get_users (receiver, in_channel_cb, {get_cmd=get_cmd, receiver=receiver, msg=msg, user_id=user_id}) - elseif matches[1] == "block" and matches[2] and not string.match(matches[2], '^%d+$') then - --[[local cbres_extra = { - channelid = msg.to.id, - get_cmd = 'channel_block', - sender = msg.from.id - } - local username = matches[2] - local username = string.gsub(matches[2], '@', '') - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] kicked: @"..username) - resolve_username(username, callbackres, cbres_extra)]] - local get_cmd = 'channel_block' - local msg = msg - local username = matches[2] - local username = string.gsub(matches[2], '@', '') - channel_get_users (receiver, in_channel_cb, {get_cmd=get_cmd, receiver=receiver, msg=msg, username=username}) - end - end - - if matches[1] == 'id' then - if type(msg.reply_id) ~= "nil" and is_momod(msg) and not matches[2] then - local cbreply_extra = { - get_cmd = 'id', - msg = msg - } - get_message(msg.reply_id, get_message_callback, cbreply_extra) - elseif type(msg.reply_id) ~= "nil" and matches[2] == "from" and is_momod(msg) then - local cbreply_extra = { - get_cmd = 'idfrom', - msg = msg - } - get_message(msg.reply_id, get_message_callback, cbreply_extra) - elseif msg.text:match("@[%a%d]") then - local cbres_extra = { - channelid = msg.to.id, - get_cmd = 'id' - } - local username = matches[2] - local username = username:gsub("@","") - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested ID for: @"..username) - resolve_username(username, callbackres, cbres_extra) - else - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup ID") - return "Group id : "..msg.to.id.."\nYour id : "..msg.from.id.."\nYour Name : "..msg.from.first_name.."" - end - end - - if matches[1] == 'kickme' then - if msg.to.type == 'channel' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] left via kickme") - channel_kick("channel#id"..msg.to.id, "user#id"..msg.from.id, ok_cb, false) - end - end - - if matches[1] == 'newlink' and is_momod(msg)then - local function callback_link (extra , success, result) - local receiver = get_receiver(msg) - if success == 0 then - send_large_msg(receiver, '*Error: Failed to retrieve link* \nReason: Not creator.\n\nIf you have the link, please use /setlink to set it') - data[tostring(msg.to.id)]['settings']['set_link'] = nil - save_data(_config.moderation.data, data) - else - send_large_msg(receiver, "Created a new link") - data[tostring(msg.to.id)]['settings']['set_link'] = result - save_data(_config.moderation.data, data) - end - end - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] attempted to create a new SuperGroup link") - export_channel_link(receiver, callback_link, false) - end - - if matches[1] == 'setlink' and is_owner(msg) then - data[tostring(msg.to.id)]['settings']['set_link'] = 'waiting' - save_data(_config.moderation.data, data) - return 'Please send the new group link now' - end - - if msg.text then - if msg.text:match("^(https://telegram.me/joinchat/%S+)$") and data[tostring(msg.to.id)]['settings']['set_link'] == 'waiting' and is_owner(msg) then - data[tostring(msg.to.id)]['settings']['set_link'] = msg.text - save_data(_config.moderation.data, data) - return "New link set" - end - end - - if matches[1] == 'link' then - if not is_momod(msg) then - return - end - local group_link = data[tostring(msg.to.id)]['settings']['set_link'] - if not group_link then - return "Create a link using /newlink first!\n\nOr if I am not creator use /setlink to set your link" - end - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group link ["..group_link.."]") - return "Group link:\n"..group_link - end - - if matches[1] == "invite" and is_sudo(msg) then - local cbres_extra = { - channel = get_receiver(msg), - get_cmd = "invite" - } - local username = matches[2] - local username = username:gsub("@","") - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] invited @"..username) - resolve_username(username, callbackres, cbres_extra) - end - - if matches[1] == 'res' and is_owner(msg) then - local cbres_extra = { - channelid = msg.to.id, - get_cmd = 'res' - } - local username = matches[2] - local username = username:gsub("@","") - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] resolved username: @"..username) - resolve_username(username, callbackres, cbres_extra) - end - - if matches[1] == 'kick' and is_momod(msg) then - local receiver = channel..matches[3] - local user = "user#id"..matches[2] - chaannel_kick(receiver, user, ok_cb, false) - end - - if matches[1] == 'setadmin' then - if not is_support(msg.from.id) and not is_owner(msg) then - return - end - if type(msg.reply_id) ~= "nil" then - local cbreply_extra = { - get_cmd = 'setadmin', - msg = msg - } - setadmin = get_message(msg.reply_id, get_message_callback, cbreply_extra) - elseif matches[1] == 'setadmin' and matches[2] and string.match(matches[2], '^%d+$') then - --[[] local receiver = get_receiver(msg) - local user_id = "user#id"..matches[2] - local get_cmd = 'setadmin' - user_info(user_id, cb_user_info, {receiver = receiver, get_cmd = get_cmd})]] - local get_cmd = 'setadmin' - local msg = msg - local user_id = matches[2] - channel_get_users (receiver, in_channel_cb, {get_cmd=get_cmd, receiver=receiver, msg=msg, user_id=user_id}) - elseif matches[1] == 'setadmin' and matches[2] and not string.match(matches[2], '^%d+$') then - --[[local cbres_extra = { - channel = get_receiver(msg), - get_cmd = 'setadmin' - } - local username = matches[2] - local username = string.gsub(matches[2], '@', '') - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set admin @"..username) - resolve_username(username, callbackres, cbres_extra)]] - local get_cmd = 'setadmin' - local msg = msg - local username = matches[2] - local username = string.gsub(matches[2], '@', '') - channel_get_users (receiver, in_channel_cb, {get_cmd=get_cmd, receiver=receiver, msg=msg, username=username}) - end - end - - if matches[1] == 'demoteadmin' then - if not is_support(msg.from.id) and not is_owner(msg) then - return - end - if type(msg.reply_id) ~= "nil" then - local cbreply_extra = { - get_cmd = 'demoteadmin', - msg = msg - } - demoteadmin = get_message(msg.reply_id, get_message_callback, cbreply_extra) - elseif matches[1] == 'demoteadmin' and matches[2] and string.match(matches[2], '^%d+$') then - local receiver = get_receiver(msg) - local user_id = "user#id"..matches[2] - local get_cmd = 'demoteadmin' - user_info(user_id, cb_user_info, {receiver = receiver, get_cmd = get_cmd}) - elseif matches[1] == 'demoteadmin' and matches[2] and not string.match(matches[2], '^%d+$') then - local cbres_extra = { - channel = get_receiver(msg), - get_cmd = 'demoteadmin' - } - local username = matches[2] - local username = string.gsub(matches[2], '@', '') - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted admin @"..username) - resolve_username(username, callbackres, cbres_extra) - end - end - - if matches[1] == 'setowner' and is_owner(msg) then - if type(msg.reply_id) ~= "nil" then - local cbreply_extra = { - get_cmd = 'setowner', - msg = msg - } - setowner = get_message(msg.reply_id, get_message_callback, cbreply_extra) - elseif matches[1] == 'setowner' and matches[2] and string.match(matches[2], '^%d+$') then - --[[ local group_owner = data[tostring(msg.to.id)]['set_owner'] - if group_owner then - local receiver = get_receiver(msg) - local user_id = "user#id"..group_owner - if not is_admin2(group_owner) and not is_support(group_owner) then - channel_demote(receiver, user_id, ok_cb, false) - end - local user = "user#id"..matches[2] - channel_set_admin(receiver, user, ok_cb, false) - data[tostring(msg.to.id)]['set_owner'] = tostring(matches[2]) - save_data(_config.moderation.data, data) - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set ["..matches[2].."] as owner") - local text = "[ "..matches[2].." ] added as owner" - return text - end]] - local get_cmd = 'setowner' - local msg = msg - local user_id = matches[2] - channel_get_users (receiver, in_channel_cb, {get_cmd=get_cmd, receiver=receiver, msg=msg, user_id=user_id}) - elseif matches[1] == 'setowner' and matches[2] and not string.match(matches[2], '^%d+$') then - local get_cmd = 'setowner' - local msg = msg - local username = matches[2] - local username = string.gsub(matches[2], '@', '') - channel_get_users (receiver, in_channel_cb, {get_cmd=get_cmd, receiver=receiver, msg=msg, username=username}) - end - end - - if matches[1] == 'promote' then - if not is_momod(msg) then - return - end - if not is_owner(msg) then - return "Only owner/admin can promote" - end - if type(msg.reply_id) ~= "nil" then - local cbreply_extra = { - get_cmd = 'promote', - msg = msg - } - promote = get_message(msg.reply_id, get_message_callback, cbreply_extra) - elseif matches[1] == 'promote' and matches[2] and string.match(matches[2], '^%d+$') then - local receiver = get_receiver(msg) - local user_id = "user#id"..matches[2] - local get_cmd = 'promote' - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted user#id"..matches[2]) - user_info(user_id, cb_user_info, {receiver = receiver, get_cmd = get_cmd}) - elseif matches[1] == 'promote' and matches[2] and not string.match(matches[2], '^%d+$') then - local cbres_extra = { - channel = get_receiver(msg), - get_cmd = 'promote', - } - local username = matches[2] - local username = string.gsub(matches[2], '@', '') - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted @"..username) - return resolve_username(username, callbackres, cbres_extra) - end - end - - if matches[1] == 'mp' and is_sudo(msg) then - channel = get_receiver(msg) - user_id = 'user#id'..matches[2] - channel_set_mod(channel, user_id, ok_cb, false) - return "ok" - end - if matches[1] == 'md' and is_sudo(msg) then - channel = get_receiver(msg) - user_id = 'user#id'..matches[2] - channel_demote(channel, user_id, ok_cb, false) - return "ok" - end - - if matches[1] == 'demote' then - if not is_momod(msg) then - return - end - if not is_owner(msg) then - return "Only owner/support/admin can promote" - end - if type(msg.reply_id) ~= "nil" then - local cbreply_extra = { - get_cmd = 'demote', - msg = msg - } - demote = get_message(msg.reply_id, get_message_callback, cbreply_extra) - elseif matches[1] == 'demote' and matches[2] and string.match(matches[2], '^%d+$') then - local receiver = get_receiver(msg) - local user_id = "user#id"..matches[2] - local get_cmd = 'demote' - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted user#id"..matches[2]) - user_info(user_id, cb_user_info, {receiver = receiver, get_cmd = get_cmd}) - elseif matches[1] == 'demote' and matches[2] and not string.match(matches[2], '^%d+$') then - local cbres_extra = { - channel = get_receiver(msg), - get_cmd = 'demote' - } - local username = matches[2] - local username = string.gsub(matches[2], '@', '') - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted @"..username) - return resolve_username(username, callbackres, cbres_extra) - end - end - - if matches[1] == "setname" and is_momod(msg) then - local receiver = get_receiver(msg) - local set_name = string.gsub(matches[2], '_', '') - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] renamed SuperGroup to: "..matches[2]) - rename_channel(receiver, set_name, ok_cb, false) - end - - if msg.service and msg.action.type == 'chat_rename' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] renamed SuperGroup to: "..msg.to.title) - data[tostring(msg.to.id)]['settings']['set_name'] = msg.to.title - save_data(_config.moderation.data, data) - end - - if matches[1] == "setabout" and is_momod(msg) then - local receiver = get_receiver(msg) - local about_text = matches[2] - local data_cat = 'description' - local target = msg.to.id - data[tostring(target)][data_cat] = about_text - save_data(_config.moderation.data, data) - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup description to: "..about_text) - channel_set_about(receiver, about_text, ok_cb, false) - return "Description has been set.\n\nSelect the chat again to see the changes." - end - - if matches[1] == "setusername" and is_admin1(msg) then - local function ok_username_cb (extra, success, result) - local receiver = extra.receiver - if success == 1 then - send_large_msg(receiver, "SuperGroup username Set.\n\nSelect the chat again to see the changes.") - elseif success == 0 then - send_large_msg(receiver, "Failed to set SuperGroup username.\nUsername may already be taken.\n\nNote: Username can use a-z, 0-9 and underscores.\nMinimum length is 5 characters.") - end - end - local username = string.gsub(matches[2], '@', '') - channel_set_username(receiver, username, ok_username_cb, {receiver=receiver}) - end - - if matches[1] == 'setrules' and is_momod(msg) then - rules = matches[2] - local target = msg.to.id - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group rules to ["..matches[2].."]") - return set_rulesmod(msg, data, target) - end - - if msg.media then - if msg.media.type == 'photo' and data[tostring(msg.to.id)]['settings']['set_photo'] == 'waiting' and is_momod(msg) then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set new SuperGroup photo") - load_photo(msg.id, set_supergroup_photo, msg) - return - end - end - if matches[1] == 'setphoto' and is_momod(msg) then - data[tostring(msg.to.id)]['settings']['set_photo'] = 'waiting' - save_data(_config.moderation.data, data) - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] started setting new SuperGroup photo") - return 'Please send the new group photo now' - end - - if matches[1] == 'clean' then - if not is_momod(msg) then - return - end - if is_momod(msg) then - if matches[2] == 'banlist' and is_momod(msg) then - local hash = 'banned' - local data_cat = 'banlist' - data[tostring(msg.to.id)][data_cat] = nil - save_data(_config.moderation.data, data) - send_large_msg(get_receiver(msg), "ban list Cleare now") - redis:del(hash) - end - if matches[2] == 'gbl' and is_sudo(msg) then - local hash = 'gbanned' - local data_cat = 'gbanlist' - data[tostring(msg.to.id)][data_cat] = nil - save_data(_config.moderation.data, data) - send_large_msg(get_receiver(msg), "Gban list Cleare now") - redis:del(hash) - end - - if matches[2] == 'modlist' then - if next(data[tostring(msg.to.id)]['moderators']) == nil then - return 'No moderator(s) in this SuperGroup.' - end - for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do - data[tostring(msg.to.id)]['moderators'][tostring(k)] = nil - save_data(_config.moderation.data, data) - end - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned modlist") - return 'Modlist has been cleaned' - end - if matches[2] == 'rules' then - local data_cat = 'rules' - if data[tostring(msg.to.id)][data_cat] == nil then - return "Rules have not been set" - end - data[tostring(msg.to.id)][data_cat] = nil - save_data(_config.moderation.data, data) - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned rules") - return 'Rules have been cleaned' - end - if matches[2] == 'about' then - local receiver = get_receiver(msg) - local about_text = ' ' - local data_cat = 'description' - if data[tostring(msg.to.id)][data_cat] == nil then - return 'About is not set' - end - data[tostring(msg.to.id)][data_cat] = nil - save_data(_config.moderation.data, data) - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned about") - channel_set_about(receiver, about_text, ok_cb, false) - return "About has been cleaned" - end - if matches[2] == 'mutelist' then - chat_id = msg.to.id - local hash = 'mute_user:'..chat_id - redis:del(hash) - return "Mutelist Cleaned" - end - if matches[2] == 'username' and is_admin1(msg) then - local function ok_username_cb (extra, success, result) - local receiver = extra.receiver - if success == 1 then - send_large_msg(receiver, "SuperGroup username cleaned.") - elseif success == 0 then - send_large_msg(receiver, "Failed to clean SuperGroup username.") - end - end - local username = "" - channel_set_username(receiver, username, ok_username_cb, {receiver=receiver}) - end - if matches[2] == "bots" and is_momod(msg) then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] kicked all SuperGroup bots") - channel_get_bots(receiver, callback_clean_bots, {msg = msg}) - end - end - if matches[2] == "members" and is_sudo(msg) then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] kicked all SuperGroup members") - channel_get_users(receiver, callback_clean_members, {msg = msg}) - end - if matches[2] == "deleted" and is_momod(msg) then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] kicked all SuperGroup Deleted Accounts !") - channel_get_users(receiver, check_member_super_deleted,{receiver = receiver, msg = msg}) - end - end - - - if matches[1] == 'lock' and is_momod(msg) then - local target = msg.to.id - if matches[2] == 'links' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked link posting ") - return lock_group_links(msg, data, target) - end - if matches[2] == 'spam' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked spam ") - return lock_group_spam(msg, data, target) - end - if matches[2] == 'flood' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked flood ") - return lock_group_flood(msg, data, target) - end - if matches[2] == 'arabic' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked arabic ") - return lock_group_arabic(msg, data, target) - end - if matches[2] == 'tag' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked tag ") - return lock_group_tag(msg, data, target) - end - if matches[2] == 'fwd' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked fwd ") - return lock_group_fwd(msg, data, target) - end - if matches[2] == 'hashtag' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked hashtag ") - return lock_group_hashtag(msg, data, target) - end - if matches[2] == 'reply' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked reply ") - return lock_group_reply(msg, data, target) - end - if matches[2] == 'member' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked member ") - return lock_group_membermod(msg, data, target) - end - if matches[2]:lower() == 'rtl' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked rtl chars. in names") - return lock_group_rtl(msg, data, target) - end - if matches[2] == 'tgservice' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked Tgservice Actions") - return lock_group_tgservice(msg, data, target) - end - - if matches[2] == 'sticker' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked sticker posting") - return lock_group_sticker(msg, data, target) - end - if matches[2] == 'badword' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked badword Actions") - return lock_group_badword(msg, data, target) - end - - if matches[2] == 'emoji' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked emoji posting") - return lock_group_emoji(msg, data, target) - end - if matches[2] == 'contacts' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked contact posting") - return lock_group_contacts(msg, data, target) - end - if matches[2] == 'strict' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked enabled strict settings") - return enable_strict_rules(msg, data, target) - end - - end - - if matches[1] == 'unlock' and is_momod(msg) then - local target = msg.to.id - if matches[2] == 'links' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked link posting") - return unlock_group_links(msg, data, target) - end - if matches[2] == 'badword' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked badword posting") - return unlock_group_badword(msg, data, target) - end - if matches[2] == 'emoji' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked emoji posting") - return unlock_group_emoji(msg, data, target) - end - if matches[2] == 'spam' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked spam") - return unlock_group_spam(msg, data, target) - end - if matches[2] == 'flood' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked flood") - return unlock_group_flood(msg, data, target) - end - if matches[2] == 'arabic' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked Arabic") - return unlock_group_arabic(msg, data, target) - end - if matches[2] == 'hashtag' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked hashtag") - return unlock_group_hashtag(msg, data, target) - end - if matches[2] == 'reply' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked reply") - return unlock_group_reply(msg, data, target) - end - if matches[2] == 'tag' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked tag") - return unlock_group_tag(msg, data, target) - end - if matches[2] == 'fwd' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked fwd") - return unlock_group_fwd(msg, data, target) - end - if matches[2] == 'member' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked member ") - return unlock_group_membermod(msg, data, target) - end - if matches[2]:lower() == 'rtl' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked RTL chars. in names") - return unlock_group_rtl(msg, data, target) - end - if matches[2] == 'tgservice' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked tgservice actions") - return unlock_group_tgservice(msg, data, target) - end - if matches[2] == 'sticker' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked sticker posting") - return unlock_group_sticker(msg, data, target) - end - if matches[2] == 'contacts' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked contact posting") - return unlock_group_contacts(msg, data, target) - end - if matches[2] == 'strict' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked disabled strict settings") - return disable_strict_rules(msg, data, target) - end - end - - if matches[1] == 'setflood' then - if not is_momod(msg) then - return - end - if tonumber(matches[2]) < 5 or tonumber(matches[2]) > 20 then - return "Wrong number,range is [5-20]" - end - local flood_max = matches[2] - data[tostring(msg.to.id)]['settings']['flood_msg_max'] = flood_max - save_data(_config.moderation.data, data) - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set flood to ["..matches[2].."]") - return 'Flood has been set to: '..matches[2] - end - if matches[1] == 'public' and is_momod(msg) then - local target = msg.to.id - if matches[2] == 'yes' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: public") - return set_public_membermod(msg, data, target) - end - if matches[2] == 'no' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: not public") - return unset_public_membermod(msg, data, target) - end - end - - if matches[1] == 'mute' and is_momod(msg) then - local chat_id = msg.to.id - if matches[2] == 'audio' then - local msg_type = 'Audio' - if not is_muted(chat_id, msg_type..': yes') then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: mute "..msg_type) - mute(chat_id, msg_type) - return msg_type.." has been muted" - else - return "SuperGroup mute "..msg_type.." is already on" - end - end - if matches[2] == 'photo' then - local msg_type = 'Photo' - if not is_muted(chat_id, msg_type..': yes') then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: mute "..msg_type) - mute(chat_id, msg_type) - return msg_type.." has been muted" - else - return "SuperGroup mute "..msg_type.." is already on" - end - end - if matches[2] == 'video' then - local msg_type = 'Video' - if not is_muted(chat_id, msg_type..': yes') then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: mute "..msg_type) - mute(chat_id, msg_type) - return msg_type.." has been muted" - else - return "SuperGroup mute "..msg_type.." is already on" - end - end - if matches[2] == 'gifs' then - local msg_type = 'Gifs' - if not is_muted(chat_id, msg_type..': yes') then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: mute "..msg_type) - mute(chat_id, msg_type) - return msg_type.." have been muted" - else - return "SuperGroup mute "..msg_type.." is already on" - end - end - if matches[2] == 'documents' then - local msg_type = 'Documents' - if not is_muted(chat_id, msg_type..': yes') then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: mute "..msg_type) - mute(chat_id, msg_type) - return msg_type.." have been muted" - else - return "SuperGroup mute "..msg_type.." is already on" - end - end - if matches[2] == 'text' then - local msg_type = 'Text' - if not is_muted(chat_id, msg_type..': yes') then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: mute "..msg_type) - mute(chat_id, msg_type) - return msg_type.." has been muted" - else - return "Mute "..msg_type.." is already on" - end - end - if matches[2] == 'all' then - local msg_type = 'All' - if not is_muted(chat_id, msg_type..': yes') then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: mute "..msg_type) - mute(chat_id, msg_type) - return "Mute "..msg_type.." has been enabled" - else - return "Mute "..msg_type.." is already on" - end - end - end - if matches[1] == 'unmute' and is_momod(msg) then - local chat_id = msg.to.id - if matches[2] == 'audio' then - local msg_type = 'Audio' - if is_muted(chat_id, msg_type..': yes') then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: unmute "..msg_type) - unmute(chat_id, msg_type) - return msg_type.." has been unmuted" - else - return "Mute "..msg_type.." is already off" - end - end - if matches[2] == 'photo' then - local msg_type = 'Photo' - if is_muted(chat_id, msg_type..': yes') then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: unmute "..msg_type) - unmute(chat_id, msg_type) - return msg_type.." has been unmuted" - else - return "Mute "..msg_type.." is already off" - end - end - if matches[2] == 'video' then - local msg_type = 'Video' - if is_muted(chat_id, msg_type..': yes') then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: unmute "..msg_type) - unmute(chat_id, msg_type) - return msg_type.." has been unmuted" - else - return "Mute "..msg_type.." is already off" - end - end - if matches[2] == 'gifs' then - local msg_type = 'Gifs' - if is_muted(chat_id, msg_type..': yes') then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: unmute "..msg_type) - unmute(chat_id, msg_type) - return msg_type.." have been unmuted" - else - return "Mute "..msg_type.." is already off" - end - end - if matches[2] == 'documents' then - local msg_type = 'Documents' - if is_muted(chat_id, msg_type..': yes') then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: unmute "..msg_type) - unmute(chat_id, msg_type) - return msg_type.." have been unmuted" - else - return "Mute "..msg_type.." is already off" - end - end - if matches[2] == 'text' then - local msg_type = 'Text' - if is_muted(chat_id, msg_type..': yes') then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: unmute message") - unmute(chat_id, msg_type) - return msg_type.." has been unmuted" - else - return "Mute text is already off" - end - end - if matches[2] == 'all' then - local msg_type = 'All' - if is_muted(chat_id, msg_type..': yes') then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: unmute "..msg_type) - unmute(chat_id, msg_type) - return "Mute "..msg_type.." has been disabled" - else - return "Mute "..msg_type.." is already disabled" - end - end - end - - - if matches[1] == "muteuser" and is_momod(msg) then - local chat_id = msg.to.id - local hash = "mute_user"..chat_id - local user_id = "" - if type(msg.reply_id) ~= "nil" then - local receiver = get_receiver(msg) - local get_cmd = "mute_user" - muteuser = get_message(msg.reply_id, get_message_callback, {receiver = receiver, get_cmd = get_cmd, msg = msg}) - elseif matches[1] == "muteuser" and matches[2] and string.match(matches[2], '^%d+$') then - local user_id = matches[2] - if is_muted_user(chat_id, user_id) then - unmute_user(chat_id, user_id) - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] removed ["..user_id.."] from the muted users list") - return "["..user_id.."] removed from the muted users list" - elseif is_owner(msg) then - mute_user(chat_id, user_id) - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] added ["..user_id.."] to the muted users list") - return "["..user_id.."] added to the muted user list" - end - elseif matches[1] == "muteuser" and matches[2] and not string.match(matches[2], '^%d+$') then - local receiver = get_receiver(msg) - local get_cmd = "mute_user" - local username = matches[2] - local username = string.gsub(matches[2], '@', '') - resolve_username(username, callbackres, {receiver = receiver, get_cmd = get_cmd, msg=msg}) - end - end - - if matches[1] == "muteslist" and is_momod(msg) then - local chat_id = msg.to.id - if not has_mutes(chat_id) then - set_mutes(chat_id) - return mutes_list(chat_id) - end - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup muteslist") - return mutes_list(chat_id) - end - if matches[1] == "mutelist" and is_momod(msg) then - local chat_id = msg.to.id - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup mutelist") - return muted_user_list(chat_id) - end - - if matches[1] == 'settings' and is_momod(msg) then - local target = msg.to.id - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup settings ") - return show_supergroup_settingsmod(msg, target) - end - - if matches[1] == 'rules' then - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group rules") - return get_rules(msg, data) - end - - if matches[1] == 'help' and not is_owner(msg) then - text = "It's Special for Owners and Admins . if you want to see my Commands Please send the /help to my Private" - reply_msg(msg.id, text, ok_cb, false) - elseif matches[1] == 'help' and is_owner(msg) then - local name_log = user_print_name(msg.from) - --savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /superhelp") - return super_help() - end - - if matches[1] == 'peer_id' and is_admin1(msg)then - text = msg.to.peer_id - reply_msg(msg.id, text, ok_cb, false) - post_large_msg(receiver, text) - end - - if matches[1] == 'msg.to.id' and is_admin1(msg) then - text = msg.to.id - reply_msg(msg.id, text, ok_cb, false) - post_large_msg(receiver, text) - end - - --Admin Join Service Message - if msg.service then - local action = msg.action.type - if action == 'chat_add_user_link' then - if is_owner2(msg.from.id) then - local receiver = get_receiver(msg) - local user = "user#id"..msg.from.id - --savelog(msg.to.id, name_log.." Admin ["..msg.from.id.."] joined the SuperGroup via link") - channel_set_admin(receiver, user, ok_cb, false) - end - if is_support(msg.from.id) and not is_owner2(msg.from.id) then - local receiver = get_receiver(msg) - local user = "user#id"..msg.from.id - --savelog(msg.to.id, name_log.." Support member ["..msg.from.id.."] joined the SuperGroup") - channel_set_mod(receiver, user, ok_cb, false) - end - end - if action == 'chat_add_user' then - if is_owner2(msg.action.user.id) then - local receiver = get_receiver(msg) - local user = "user#id"..msg.action.user.id - --savelog(msg.to.id, name_log.." Admin ["..msg.action.user.id.."] added to the SuperGroup by [ "..msg.from.id.." ]") - channel_set_admin(receiver, user, ok_cb, false) - end - if is_support(msg.action.user.id) and not is_owner2(msg.action.user.id) then - local receiver = get_receiver(msg) - local user = "user#id"..msg.action.user.id - --savelog(msg.to.id, name_log.." Support member ["..msg.action.user.id.."] added to the SuperGroup by [ "..msg.from.id.." ]") - channel_set_mod(receiver, user, ok_cb, false) - end - end - end - if matches[1] == 'msg.to.peer_id' then - post_large_msg(receiver, msg.to.peer_id) - end - end -end - -local function pre_process(msg) - if not msg.text and msg.media then - msg.text = '['..msg.media.type..']' - end - return msg -end - -return { - patterns = { - "^[#!/]([Aa]dd)$", - "^[#!/]([Rr]em)$", - "^[#!/]([Mm]ove) (.*)$", - "^[#!/]([Gg]pinfo)$", - "^[#!/]([Aa]dmins)$", - "^[#!/]([Oo]wner)$", - "^[#!/]([Mm]odlist)$", - "^[#!/]([Bb]ots)$", - "^[#!/]([Ww]ho)$", - "^[#!/]([Kk]icked)$", - "^[#!/]([Bb]lock) (.*)", - "^[#!/]([Bb]lock)", - "^[#!/]([Kk]ick) (.*)", - "^[#!/]([Kk]ick)", - "^[#!/]([Tt]osuper)$", - "^[#!/]([Ii][Dd]) (.*)$", - "^[#!/]([Ii][Dd])$", - "^[#!/]([Nn]ewlink)$", - "^[#!/]([Ss]etlink)$", - "^[#!/]([Ll]ink)$", - "^[#!/]([Rr]es) (.*)$", - "^[#!/]([Ss]etadmin) (.*)$", - "^[#!/]([Ss]etadmin)", - "^[#!/]([Dd]emoteadmin) (.*)$", - "^[#!/]([Dd]emoteadmin)", - "^[#!/]([Ss]etowner) (.*)$", - "^[#!/]([Ss]etowner)$", - "^[#!/]([Pp]romote) (.*)$", - "^[#!/]([Pp]romote)", - "^[#!/]([Dd]emote) (.*)$", - "^[#!/]([Dd]emote)", - "^[#!/]([Ss]etname) (.*)$", - "^[#!/]([Ss]etabout) (.*)$", - "^[#!/]([Ss]etrules) (.*)$", - "^[#!/]([Ss]etphoto)$", - "^[#!/]([Ss]etusername) (.*)$", - "^[#!/]([Dd]el)$", - "^[#!/]([Ll]ock) (.*)$", - "^[#!/]([Uu]nlock) (.*)$", - "^[#!/]([Mm]ute) ([^%s]+)$", - "^[#!/]([Uu]nmute) ([^%s]+)$", - "^[#!/]([Mm]uteuser)$", - "^[#!/]([Mm]uteuser) (.*)$", - "^[#!/]([Pp]ublic) (.*)$", - "^[#!/]([Ss]ettings)$", - "^[#!/]([Rr]ules)$", - "^[#!/]([Ss]etflood) (%d+)$", - "^[#!/]([Cc]lean) (.*)$", - "^[#!/]([Mm]uteslist)$", - "^[#!/]([Mm]utelist)$", - "[#!/](mp) (.*)", - "[#!/](md) (.*)", - "^[/!#]([Uu]nlimite)(%d+)(.*)$", - "^[/!#]([Uu]nlimite)(%d+) (.*)$", - "^[/!#]([Uu]nlimite)(%d+)$", - "^[/!#]([Ll]eave)(%d+) (.*)$", - "^[/!#]([Ll]eave)(%d+)(.*)$", - "^[/!#]([Ll]eave)(%d+)$", -"^[/!#]([Ll]eave)$", - "^[/!#]([Jj]oin)(%d+)$", - "^[/!#](3[Mm])(%d+)(.*)$", - "^[/!#](3[Mm])(%d+) (.*)$", - "^[/!#](3[Mm])(%d+)$", - "^[/!#](1[Mm])(%d+)(.*)$", - "^[/!#](1[Mm])(%d+) (.*)$", - "^[/!#](1[Mm])(%d+)$", - "^[/!#]([Jj]oin)(%d+)$", - "^(https://telegram.me/joinchat/%S+)$", - "msg.to.peer_id", - "%[(document)%]", - "%[(photo)%]", - "%[(video)%]", - "%[(audio)%]", - "%[(contact)%]", - "^!!tgservice (.+)$", - }, - run = run, - pre_process = pre_process -} ---End supergrpup.lua ---By @Rondoozle