diff --git a/bot/seedbot.lua b/bot/seedbot.lua index 09e98d4e..c4580a53 100644 --- a/bot/seedbot.lua +++ b/bot/seedbot.lua @@ -230,9 +230,13 @@ function create_config( ) "leave_ban", "supergroup", "whitelist", - "msg_checks" + "msg_checks", +"aparat", +"azan", +"joke", +"rmsg", }, - sudo_users = {110626080,103649648,111020322,0,tonumber(our_id)},--Sudo users + sudo_users = {(277313212)},--Sudo users moderation = {data = 'data/moderation.json'}, about_text = [[Teleseed v4 An advanced administration bot based on TG-CLI written in Lua @@ -343,274 +347,242 @@ This command will send text to [group_id] *Only admins and sudo can use res, setowner, commands ]], help_text = [[ -Commands list : - -!kick [username|id] -You can also do it by reply - -!ban [ username|id] -You can also do it by reply - -!unban [id] -You can also do it by reply - -!who -Members list - +لیست درستورات در مینی گپ +!info +نمایش اطلاعات کلی در مورد +_____________________________ +!owner +صاحب گروه +_____________________________ !modlist -Moderators list - -!promote [username] -Promote someone - -!demote [username] -Demote someone - +لیست مدیران +_____________________________ +!bots +لیست رباتها در SuperGroup +_____________________________ +!who +لیست تمام کاربران در SuperGroup +_____________________________ +!block +حذف از گروه +_____________________________ +!banlist +لیست مسدودین +!ban +ممنوعیت از گروه براهمیشه +!unban +رفع ممنویت ازگروه +______________________________ +!id +ایدی مدنظر +!id from +ایدی من +_______________________________ !kickme -Will kick user - -!about -Group description - +حذف من از گروه +_______________________________ +!setowner +صاحب جدیدگروه +_______________________________ +!promote [username|id] +مدیرکردن «ایدی"ریپیلی"یوزرایدی» +!demote [username|id] +حذف مدریت +«ایدی"ریپیلی"یوزرایدی» +________________________________ +setname +اسم برای پروفایل گروه !setphoto -Set and locks group photo - -!setname [name] -Set group name - +عکس برای پروفایل گروه +!setrules +تنظیم قوانین چت +!setabout +تنظیم اعطلاعات چت +!save [value] +سیو متن +__________________________________ +!get [value] +اطلاعات اضافی برای چت +__________________________________ +!newlink +لینک جدید +!link +لینک گروه +!setlink +ست کردن لینک +__________________________________ !rules -Group rules - -!id -return group id or user id - -!help -Returns help text - +قوانین گروه +__________________________________ !lock [links|flood|spam|Arabic|member|rtl|sticker|contacts|strict] Lock group settings -*rtl: Kick user if Right To Left Char. is in name* - +قفل کردن ........................... !unlock [links|flood|spam|Arabic|member|rtl|sticker|contacts|strict] Unlock group settings -*rtl: Kick user if Right To Left Char. is in name* - -!mute [all|audio|gifs|photo|video] -mute group message types -*If "muted" message type: user is kicked if message type is posted - -!unmute [all|audio|gifs|photo|video] -Unmute group message types -*If "unmuted" message type: user is not kicked if message type is posted - -!set rules -Set as rules - -!set about -Set as about - -!settings -Returns group settings - -!muteslist -Returns mutes for chat - -!muteuser [username] -Mute a user in chat -*user is kicked if they talk -*only owners can mute | mods and owners can unmute - -!mutelist -Returns list of muted users in chat - -!newlink -create/revoke your group link - -!link -returns group link - -!owner -returns group owner id - -!setowner [id] -Will set id as owner - +بازکردن............................... +__________________________________ !setflood [value] -Set [value] as flood sensitivity - -!stats -Simple message statistics - -!save [value] -Save as [value] - -!get [value] -Returns text of [value] - -!clean [modlist|rules|about] -Will clear [modlist|rules|about] and set it to nil - -!res [username] -returns user id -"!res @username" - -!log -Returns group logs - -!banlist -will return group ban list - -**You can use "#", "!", or "/" to begin all commands - - -*Only owner and mods can add bots in group - - -*Only moderators and owner can use kick,ban,unban,newlink,link,setphoto,setname,lock,unlock,set rules,set about and settings commands - -*Only owner can use res,setowner,promote,demote and log commands - +حساسیت 5تا20 +___________________________________ +!settings +تنظیمات +___________________________________ +!clean [rules|about|modlist|mutelist] +پاک کردن............................... +___________________________________ +!del +حذف پیام +___________________________________ +!aparat .... +آپارات +_______________________________ +!time ..... +ساعت +______________________________ +پاک 100 +پاک کردن 100 پیام قبل +پاک 100 +پاک کردن 100پیام قبل +_____________________________ +!bing .... +جستجو در موروگر +_________________________________________ +سودووطراح ربات ضداسپم:» +نکته »»قبل از نوشتن کلمه های بالا گذاشتن ! +!دراول دستور فراموش نشود +#ID SUDO: @Xx_SAMAN_SENATOR_edRis_xX +#ID Channel: @Xx_FUNKADHE_xX +منتظر شمادوستان گل هستیم ❤️🌹💋 +_________________________________________ ]], help_text_super =[[ -SuperGroup Commands: - +لیست دستورات سوپرگپ !info -Displays general info about the SuperGroup - +نمایش اطلاعات کلی در مورد SuperGroup +____________________________ !admins -Returns SuperGroup admins list - +SuperGroup لیست مدیران +_____________________________ !owner -Returns group owner - +صاحب گروه +_____________________________ !modlist -Returns Moderators list - +لیست مدیران +_____________________________ !bots -Lists bots in SuperGroup - +لیست رباتها در SuperGroup +_____________________________ !who -Lists all users in SuperGroup - +لیست تمام کاربران در SuperGroup +_____________________________ !block -Kicks a user from SuperGroup -*Adds user to blocked list* - +حذف از گروه +_____________________________ +!banlist +لیست مسدودین !ban -Bans user from the SuperGroup - +ممنوعیت از گروه براهمیشه !unban -Unbans user from the SuperGroup - +رفع ممنویت ازگروه +______________________________ !id -Return SuperGroup ID or user id -*For userID's: !id @username or reply !id* - +ایدی مدنظر !id from -Get ID of user message is forwarded from - +ایدی من +_______________________________ !kickme -Kicks user from SuperGroup -*Must be unblocked by owner or use join by pm to return* - +حذف من از گروه +_______________________________ !setowner -Sets the SuperGroup owner - +صاحب جدیدگروه +_______________________________ !promote [username|id] -Promote a SuperGroup moderator - +مدیرکردن «ایدی"ریپیلی"یوزرایدی» !demote [username|id] -Demote a SuperGroup moderator - -!setname -Sets the chat name - +حذف مدریت +«ایدی"ریپیلی"یوزرایدی» +________________________________ +setname +اسم برای پروفایل گروه !setphoto -Sets the chat photo - +عکس برای پروفایل گروه !setrules -Sets the chat rules - +تنظیم قوانین چت !setabout -Sets the about section in chat info(members list) - +تنظیم اعطلاعات چت !save [value] -Sets extra info for chat - +سیو متن +__________________________________ !get [value] -Retrieves extra info for chat by value - +اطلاعات اضافی برای چت +__________________________________ !newlink -Generates a new group link - +لینک جدید !link -Retireives the group link - +لینک گروه +!setlink +ست کردن لینک +__________________________________ !rules -Retrieves the chat rules - +قوانین گروه +__________________________________ !lock [links|flood|spam|Arabic|member|rtl|sticker|contacts|strict] Lock group settings -*rtl: Delete msg if Right To Left Char. is in name* -*strict: enable strict settings enforcement (violating user will be kicked)* - +قفل کردن ........................... !unlock [links|flood|spam|Arabic|member|rtl|sticker|contacts|strict] Unlock group settings -*rtl: Delete msg if Right To Left Char. is in name* -*strict: disable strict settings enforcement (violating user will not be kicked)* - +بازکردن............................... +__________________________________ !mute [all|audio|gifs|photo|video|service] mute group message types -*A "muted" message type is auto-deleted if posted - +فلیترکردن............................. !unmute [all|audio|gifs|photo|video|service] Unmute group message types -*A "unmuted" message type is not auto-deleted if posted - -!setflood [value] -Set [value] as flood sensitivity - -!settings -Returns chat settings - +ازفلیتردراوردن....................... !muteslist -Returns mutes for chat - +لیست فیلترین !muteuser [username] -Mute a user in chat -*If a muted user posts a message, the message is deleted automaically -*only owners can mute | mods and owners can unmute - -!mutelist -Returns list of muted users in chat - -!banlist -Returns SuperGroup ban list - +نادیده گرفتن یک کاربر در چت +___________________________________ +!setflood [value] +حساسیت 5تا20 +___________________________________ +!settings +تنظیمات +___________________________________ !clean [rules|about|modlist|mutelist] - +پاک کردن............................... +___________________________________ !del -Deletes a message by reply - +حذف پیام +___________________________________ !public [yes|no] -Set chat visibility in pm !chats or !chatlist commands - -!res [username] -Returns users name and id by username - - -!log -Returns group logs -*Search for kick reasons using [#RTL|#spam|#lockmember] - -**You can use "#", "!", or "/" to begin all commands - -*Only owner can add members to SuperGroup -(use invite link to invite) - -*Only moderators and owner can use block, ban, unban, newlink, link, setphoto, setname, lock, unlock, setrules, setabout and settings commands +عمومی کردن چت +____________________________ +_________________________________ +!aparat .... +آپارات +_______________________________ +!time ..... +ساعت +______________________________ +پاک 100 +پاک کردن 100 پیام قبل +پاک 100 +پاک کردن 100پیام قبل +_____________________________ +!bing .... +جستجو در موروگر +_________________________________________ +سودووطراح ربات ضداسپم:» +نکته »»قبل از نوشتن کلمه های بالا گذاشتن ! +!دراول دستور فراموش نشود +#ID SUDO: @Xx_SAMAN_SENATOR_edRis_xX +#ID Channel: @Xx_FUNKADHE_xX +منتظر شمادوستان گل هستیم ❤️🌹💋 +_________________________________________ +_________________________________________ -*Only owner can use res, setowner, promote, demote, and log commands ]], } diff --git a/plugins/aparat.lua b/plugins/aparat.lua new file mode 100644 index 00000000..134f1e5f --- /dev/null +++ b/plugins/aparat.lua @@ -0,0 +1,23 @@ + + +local function run(msg, matches) + if matches[1]:lower() == 'اپارات' then + local url = http.request('http://www.aparat.com/etc/api/videoBySearch/text/'..URL.escape(matches[2])) + local jdat = json:decode(url) + + local items = jdat.videobysearch + text = 'نتیجه جستجو در آپارات: \n' + for i = 1, #items do + text = text..'\n\n'..i..'-'..items[i].title..'\nتعداد بازدید: '..items[i].visit_cnt..'\n لینک: aparat.com/v/'..items[i].uid + end + text = text..'\n\n@Xx_FUNKADHE_xX' + return text + end +end + +return { + patterns = { +"^(اپارات) (.*)$", + }, + run = run +} diff --git a/plugins/aparatdl.lua b/plugins/aparatdl.lua new file mode 100644 index 00000000..aa84bce6 --- /dev/null +++ b/plugins/aparatdl.lua @@ -0,0 +1,56 @@ +do + local sys_messages = { + downloading = "در حال دريافت ويدئو...", + uploading = "ويدئو شما در حال بارگذاري است...", + error = "خطا در دريافت ويدئو", + not_found ="ويدئو پيدا نشد", + maxFilesize = 0, + } + local STATUS_ERROR =0 + local STATUS_404 =1 + local STATUS_SUCCESS =2 + local function dl_video(link,tag) + local video = 'aparat_' .. tag .. '.mp4' + local path = '/tmp/' .. video .. ' ' + run_command('[ -f ' .. path .. '] || curl -o ' .. path .. link ) + local result = run_command('[ -f ' .. path .. '] || echo "error"') + if result == 'error' then return nil else return video end + end + local function get_video_link(tag) + local url = "http://aparat.com/v/" .. tag + local file_pattern = +'' + local link = "" + local res,code = http.request(url) + if code ~= 200 then return STATUS_ERROR,nil end + link =string.match(res,file_pattern) + if link == "" or link== nil then return STATUS_404,link end + return STATUS_SUCCESS,link + end + local function send_video_to(receiver,video_file) + send_large_msg(receiver,sys_messages.uploading) + file = '/tmp/' .. video_file + local cb_extra = {file_path=file} + print(file) + --send_document(receiver, file, rmtmp_cb, cb_extra) + send_video(receiver, file, rmtmp_cb, cb_extra) + end + local function run(msg, matches) + local receiver = get_receiver(msg) + local status,link = get_video_link(matches[1]) + if status == STATUS_ERROR then return sys_messages.error end + if status == STATUS_404 then return sys_messages.not_found end + local video = dl_video(link,matches[1]) + if video == nil or video == "" then return sys_messages.error end + send_video_to(receiver,video) + end + return { + --description = "دانلود فيلم از سايت يوتيوب", + description = "دانلود فیلم از آپارات", + usage = "بصورت اتوماتیک لینک آپارات را تشخیص داده و فیلم را دانلود میکند", + patterns = { + "[/#!][Aa]paratdl http://aparat.com/v/([_A-Za-z0-9-]+)/?" + }, + run = run + } +end diff --git a/plugins/azan.lua b/plugins/azan.lua new file mode 100644 index 00000000..4d7bc721 --- /dev/null +++ b/plugins/azan.lua @@ -0,0 +1,100 @@ +--[[ + +# +# @GPMOD +# @Dragon_Born +# + +]] +do +function run_bash(str) + local cmd = io.popen(str) + local result = cmd:read('*all') + return result +end +local api_key = nil +local base_api = "https://maps.googleapis.com/maps/api" +function get_latlong(area) + local api = base_api .. "/geocode/json?" + local parameters = "address=".. (URL.escape(area) or "") + if api_key ~= nil then + parameters = parameters .. "&key="..api_key + end + local res, code = https.request(api..parameters) + if code ~=200 then return nil end + local data = json:decode(res) + + if (data.status == "ZERO_RESULTS") then + return nil + end + if (data.status == "OK") then + lat = data.results[1].geometry.location.lat + lng = data.results[1].geometry.location.lng + acc = data.results[1].geometry.location_type + types= data.results[1].types + return lat,lng,acc,types + end +end +function get_staticmap(area) + local api = base_api .. "/staticmap?" + local lat,lng,acc,types = get_latlong(area) + + local scale = types[1] + if scale=="locality" then zoom=8 + elseif scale=="country" then zoom=4 + else zoom = 13 end + + local parameters = + "size=600x300" .. + "&zoom=" .. zoom .. + "¢er=" .. URL.escape(area) .. + "&markers=color:red"..URL.escape("|"..area) + + if api_key ~=nil and api_key ~= "" then + parameters = parameters .. "&key="..api_key + end + return lat, lng, api..parameters +end + + +function run(msg, matches) + local hash = 'usecommands:'..msg.from.id..':'..msg.to.id + redis:incr(hash) + local receiver = get_receiver(msg) + local city = matches[1] + if matches[1] == 'praytime' then + city = 'Tehran' + end + local lat,lng,url = get_staticmap(city) + + local dumptime = run_bash('date +%s') + local code = http.request('http://api.aladhan.com/timings/'..dumptime..'?latitude='..lat..'&longitude='..lng..'&timezonestring=Asia/Tehran&method=7') + local jdat = json:decode(code) + local data = jdat.data.timings + local text = 'شهر: '..city + text = text..'\nاذان صبح: '..data.Fajr + text = text..'\nطلوع آفتاب: '..data.Sunrise + text = text..'\nاذان ظهر: '..data.Dhuhr + text = text..'\nغروب آفتاب: '..data.Sunset + text = text..'\nاذان مغرب: '..data.Maghrib + text = text..'\nعشاء : '..data.Isha + text = text..'\n @Xx_FUNKADHE_xX \n' + if string.match(text, '0') then text = string.gsub(text, '0', '۰') end + if string.match(text, '1') then text = string.gsub(text, '1', '۱') end + if string.match(text, '2') then text = string.gsub(text, '2', '۲') end + if string.match(text, '3') then text = string.gsub(text, '3', '۳') end + if string.match(text, '4') then text = string.gsub(text, '4', '۴') end + if string.match(text, '5') then text = string.gsub(text, '5', '۵') end + if string.match(text, '6') then text = string.gsub(text, '6', '۶') end + if string.match(text, '7') then text = string.gsub(text, '7', '۷') end + if string.match(text, '8') then text = string.gsub(text, '8', '۸') end + if string.match(text, '9') then text = string.gsub(text, '9', '۹') end + return text +end + +return { + patterns = {"^اذان (.*)$","^(اذان)$"}, + run = run +} + +end diff --git a/plugins/banhammer.lua b/plugins/banhammer.lua deleted file mode 100644 index 9cce9240..00000000 --- a/plugins/banhammer.lua +++ /dev/null @@ -1,348 +0,0 @@ - -local function pre_process(msg) - local data = load_data(_config.moderation.data) - -- SERVICE MESSAGE - if msg.action and msg.action.type then - local action = msg.action.type - -- Check if banned user joins chat by link - if action == 'chat_add_user_link' then - local user_id = msg.from.id - print('Checking invited user '..user_id) - local banned = is_banned(user_id, msg.to.id) - if banned or is_gbanned(user_id) then -- Check it with redis - print('User is banned!') - local print_name = user_print_name(msg.from):gsub("‮", "") - local name = print_name:gsub("_", "") - savelog(msg.to.id, name.." ["..msg.from.id.."] is banned and kicked ! ")-- Save to logs - kick_user(user_id, msg.to.id) - end - end - -- Check if banned user joins chat - if action == 'chat_add_user' then - local user_id = msg.action.user.id - print('Checking invited user '..user_id) - local banned = is_banned(user_id, msg.to.id) - if banned and not is_momod2(msg.from.id, msg.to.id) or is_gbanned(user_id) and not is_admin2(msg.from.id) then -- Check it with redis - print('User is banned!') - local print_name = user_print_name(msg.from):gsub("‮", "") - local name = print_name:gsub("_", "") - savelog(msg.to.id, name.." ["..msg.from.id.."] added a banned user >"..msg.action.user.id)-- Save to logs - kick_user(user_id, msg.to.id) - local banhash = 'addedbanuser:'..msg.to.id..':'..msg.from.id - redis:incr(banhash) - local banhash = 'addedbanuser:'..msg.to.id..':'..msg.from.id - local banaddredis = redis:get(banhash) - if banaddredis then - if tonumber(banaddredis) >= 4 and not is_owner(msg) then - kick_user(msg.from.id, msg.to.id)-- Kick user who adds ban ppl more than 3 times - end - if tonumber(banaddredis) >= 8 and not is_owner(msg) then - ban_user(msg.from.id, msg.to.id)-- Kick user who adds ban ppl more than 7 times - local banhash = 'addedbanuser:'..msg.to.id..':'..msg.from.id - redis:set(banhash, 0)-- Reset the Counter - end - end - end - if data[tostring(msg.to.id)] then - if data[tostring(msg.to.id)]['settings'] then - if data[tostring(msg.to.id)]['settings']['lock_bots'] then - bots_protection = data[tostring(msg.to.id)]['settings']['lock_bots'] - end - end - end - if msg.action.user.username ~= nil then - if string.sub(msg.action.user.username:lower(), -3) == 'bot' and not is_momod(msg) and bots_protection == "yes" then --- Will kick bots added by normal users - local print_name = user_print_name(msg.from):gsub("‮", "") - local name = print_name:gsub("_", "") - savelog(msg.to.id, name.." ["..msg.from.id.."] added a bot > @".. msg.action.user.username)-- Save to logs - kick_user(msg.action.user.id, msg.to.id) - end - end - end - -- No further checks - return msg - end - -- banned user is talking ! - if msg.to.type == 'chat' or msg.to.type == 'channel' then - local group = msg.to.id - local texttext = 'groups' - --if not data[tostring(texttext)][tostring(msg.to.id)] and not is_realm(msg) then -- Check if this group is one of my groups or not - --chat_del_user('chat#id'..msg.to.id,'user#id'..our_id,ok_cb,false) - --return - --end - local user_id = msg.from.id - local chat_id = msg.to.id - local banned = is_banned(user_id, chat_id) - if banned or is_gbanned(user_id) then -- Check it with redis - print('Banned user talking!') - local print_name = user_print_name(msg.from):gsub("‮", "") - local name = print_name:gsub("_", "") - savelog(msg.to.id, name.." ["..msg.from.id.."] banned user is talking !")-- Save to logs - kick_user(user_id, chat_id) - msg.text = '' - end - end - return msg -end - -local function kick_ban_res(extra, success, result) - local chat_id = extra.chat_id - local chat_type = extra.chat_type - if chat_type == "chat" then - receiver = 'chat#id'..chat_id - else - receiver = 'channel#id'..chat_id - end - if success == 0 then - return send_large_msg(receiver, "Cannot find user by that username!") - end - local member_id = result.peer_id - local user_id = member_id - local member = result.username - local from_id = extra.from_id - local get_cmd = extra.get_cmd - if get_cmd == "kick" then - if member_id == from_id then - send_large_msg(receiver, "You can't kick yourself") - return - end - if is_momod2(member_id, chat_id) and not is_admin2(sender) then - send_large_msg(receiver, "You can't kick mods/owner/admins") - return - end - kick_user(member_id, chat_id) - elseif get_cmd == 'ban' then - if is_momod2(member_id, chat_id) and not is_admin2(sender) then - send_large_msg(receiver, "You can't ban mods/owner/admins") - return - end - send_large_msg(receiver, 'User @'..member..' ['..member_id..'] banned') - ban_user(member_id, chat_id) - elseif get_cmd == 'unban' then - send_large_msg(receiver, 'User @'..member..' ['..member_id..'] unbanned') - local hash = 'banned:'..chat_id - redis:srem(hash, member_id) - return 'User '..user_id..' unbanned' - elseif get_cmd == 'banall' then - send_large_msg(receiver, 'User @'..member..' ['..member_id..'] globally banned') - banall_user(member_id) - elseif get_cmd == 'unbanall' then - send_large_msg(receiver, 'User @'..member..' ['..member_id..'] globally unbanned') - unbanall_user(member_id) - end -end - -local function run(msg, matches) -local support_id = msg.from.id - if matches[1]:lower() == 'id' and msg.to.type == "chat" or msg.to.type == "user" then - if msg.to.type == "user" then - return "Bot ID: "..msg.to.id.. "\n\nYour ID: "..msg.from.id - end - if type(msg.reply_id) ~= "nil" then - local print_name = user_print_name(msg.from):gsub("‮", "") - local name = print_name:gsub("_", "") - savelog(msg.to.id, name.." ["..msg.from.id.."] used /id ") - id = get_message(msg.reply_id,get_message_callback_id, false) - elseif matches[1]:lower() == 'id' then - local name = user_print_name(msg.from) - savelog(msg.to.id, name.." ["..msg.from.id.."] used /id ") - return "Group ID for " ..string.gsub(msg.to.print_name, "_", " ").. ":\n\n"..msg.to.id - end - end - if matches[1]:lower() == 'kickme' and msg.to.type == "chat" then-- /kickme - local receiver = get_receiver(msg) - if msg.to.type == 'chat' then - local print_name = user_print_name(msg.from):gsub("‮", "") - local name = print_name:gsub("_", "") - savelog(msg.to.id, name.." ["..msg.from.id.."] left using kickme ")-- Save to logs - chat_del_user("chat#id"..msg.to.id, "user#id"..msg.from.id, ok_cb, false) - end - end - - if not is_momod(msg) then -- Ignore normal users - return - end - - if matches[1]:lower() == "banlist" then -- Ban list ! - local chat_id = msg.to.id - if matches[2] and is_admin1(msg) then - chat_id = matches[2] - end - return ban_list(chat_id) - end - if matches[1]:lower() == 'ban' then-- /ban - if type(msg.reply_id)~="nil" and is_momod(msg) then - if is_admin1(msg) then - msgr = get_message(msg.reply_id,ban_by_reply_admins, false) - else - msgr = get_message(msg.reply_id,ban_by_reply, false) - end - local user_id = matches[2] - local chat_id = msg.to.id - elseif string.match(matches[2], '^%d+$') then - if tonumber(matches[2]) == tonumber(our_id) then - return - end - if not is_admin1(msg) and is_momod2(matches[2], msg.to.id) then - return "you can't ban mods/owner/admins" - end - if tonumber(matches[2]) == tonumber(msg.from.id) then - return "You can't ban your self !" - end - local print_name = user_print_name(msg.from):gsub("‮", "") - local name = print_name:gsub("_", "") - local receiver = get_receiver(msg) - savelog(msg.to.id, name.." ["..msg.from.id.."] baned user ".. matches[2]) - ban_user(matches[2], msg.to.id) - send_large_msg(receiver, 'User ['..matches[2]..'] banned') - else - local cbres_extra = { - chat_id = msg.to.id, - get_cmd = 'ban', - from_id = msg.from.id, - chat_type = msg.to.type - } - local username = string.gsub(matches[2], '@', '') - resolve_username(username, kick_ban_res, cbres_extra) - end - end - - - if matches[1]:lower() == 'unban' then -- /unban - if type(msg.reply_id)~="nil" and is_momod(msg) then - local msgr = get_message(msg.reply_id,unban_by_reply, false) - end - local user_id = matches[2] - local chat_id = msg.to.id - local targetuser = matches[2] - if string.match(targetuser, '^%d+$') then - local user_id = targetuser - local hash = 'banned:'..chat_id - redis:srem(hash, user_id) - local print_name = user_print_name(msg.from):gsub("‮", "") - local name = print_name:gsub("_", "") - savelog(msg.to.id, name.." ["..msg.from.id.."] unbaned user ".. matches[2]) - return 'User '..user_id..' unbanned' - else - local cbres_extra = { - chat_id = msg.to.id, - get_cmd = 'unban', - from_id = msg.from.id, - chat_type = msg.to.type - } - local username = string.gsub(matches[2], '@', '') - resolve_username(username, kick_ban_res, cbres_extra) - end - end - -if matches[1]:lower() == 'kick' then - if type(msg.reply_id)~="nil" and is_momod(msg) then - if is_admin1(msg) then - msgr = get_message(msg.reply_id,Kick_by_reply_admins, false) - else - msgr = get_message(msg.reply_id,Kick_by_reply, false) - end - elseif string.match(matches[2], '^%d+$') then - if tonumber(matches[2]) == tonumber(our_id) then - return - end - if not is_admin1(msg) and is_momod2(matches[2], msg.to.id) then - return "you can't kick mods/owner/admins" - end - if tonumber(matches[2]) == tonumber(msg.from.id) then - return "You can't kick your self !" - end - local user_id = matches[2] - local chat_id = msg.to.id - local print_name = user_print_name(msg.from):gsub("‮", "") - local name = print_name:gsub("_", "") - savelog(msg.to.id, name.." ["..msg.from.id.."] kicked user ".. matches[2]) - kick_user(user_id, chat_id) - else - local cbres_extra = { - chat_id = msg.to.id, - get_cmd = 'kick', - from_id = msg.from.id, - chat_type = msg.to.type - } - local username = string.gsub(matches[2], '@', '') - resolve_username(username, kick_ban_res, cbres_extra) - end -end - - - if not is_admin1(msg) and not is_support(support_id) then - return - end - - if matches[1]:lower() == 'banall' and is_admin1(msg) then -- Global ban - if type(msg.reply_id) ~="nil" and is_admin1(msg) then - banall = get_message(msg.reply_id,banall_by_reply, false) - end - local user_id = matches[2] - local chat_id = msg.to.id - local targetuser = matches[2] - if string.match(targetuser, '^%d+$') then - if tonumber(matches[2]) == tonumber(our_id) then - return false - end - banall_user(targetuser) - return 'User ['..user_id..' ] globally banned' - else - local cbres_extra = { - chat_id = msg.to.id, - get_cmd = 'banall', - from_id = msg.from.id, - chat_type = msg.to.type - } - local username = string.gsub(matches[2], '@', '') - resolve_username(username, kick_ban_res, cbres_extra) - end - end - if matches[1]:lower() == 'unbanall' then -- Global unban - local user_id = matches[2] - local chat_id = msg.to.id - if string.match(matches[2], '^%d+$') then - if tonumber(matches[2]) == tonumber(our_id) then - return false - end - unbanall_user(user_id) - return 'User ['..user_id..' ] globally unbanned' - else - local cbres_extra = { - chat_id = msg.to.id, - get_cmd = 'unbanall', - from_id = msg.from.id, - chat_type = msg.to.type - } - local username = string.gsub(matches[2], '@', '') - resolve_username(username, kick_ban_res, cbres_extra) - end - end - if matches[1]:lower() == "gbanlist" then -- Global ban list - return banall_list() - end -end - -return { - patterns = { - "^[#!/]([Bb]anall) (.*)$", - "^[#!/]([Bb]anall)$", - "^[#!/]([Bb]anlist) (.*)$", - "^[#!/]([Bb]anlist)$", - "^[#!/]([Gg]banlist)$", - "^[#!/]([Kk]ickme)", - "^[#!/]([Kk]ick)$", - "^[#!/]([Bb]an)$", - "^[#!/]([Bb]an) (.*)$", - "^[#!/]([Uu]nban) (.*)$", - "^[#!/]([Uu]nbanall) (.*)$", - "^[#!/]([Uu]nbanall)$", - "^[#!/]([Kk]ick) (.*)$", - "^[#!/]([Uu]nban)$", - "^[#!/]([Ii]d)$", - "^!!tgservice (.+)$" - }, - run = run, - pre_process = pre_process -} diff --git a/plugins/filter.lua b/plugins/filter.lua new file mode 100644 index 00000000..d88ea086 --- /dev/null +++ b/plugins/filter.lua @@ -0,0 +1,120 @@ +local function addword(msg, name) + local hash = 'chat:'..msg.to.id..':badword' + redis:hset(hash, name, 'newword') + return "New filter\n>"..name +end + +local function get_variables_hash(msg) + + return 'chat:'..msg.to.id..':badword' + +end + +-------------------filterlist------------------- +local function list_variablesbad(msg) + local hash = get_variables_hash(msg) + + if hash then + local names = redis:hkeys(hash) + local text = '⛔️FilterList🚫 :\n' + for i=1, #names do + text = text..'('..names[i]..')\n' + end + return text + else + return + end +end + +-------------------cleanfilter---------------- +function clear_commandbad(msg, var_name) + local hash = get_variables_hash(msg) + redis:del(hash, var_name) + return 'Removed' +end + +---------------------filterlist------------------ +local function list_variables2(msg, value) + local hash = get_variables_hash(msg) + + if hash then + local names = redis:hkeys(hash) + local text = '' + for i=1, #names do + if string.match(value, names[i]) and not is_momod(msg) then + if msg.to.type == 'channel' then + delete_msg(msg.id,ok_cb,false) + else + kick_user(msg.from.id, msg.to.id) + + end +return +end + end + end +end + +-------------------------get-valuebad-------------------- +local function get_valuebad(msg, var_name) + local hash = get_variables_hash(msg) + if hash then + local value = redis:hget(hash, var_name) + if not value then + return + else + return value + end + end +end + +----------------------clean-commands------------------------ +function clear_commandsbad(msg, cmd_name) + local hash = get_variables_hash(msg) + redis:hdel(hash, cmd_name) + return ''..cmd_name..' removed' +end + +--------------------run------------------- +local function run(msg, matches) + if matches[1] == 'filter' and matches[2] == '+' then + if not is_owner(msg) then + return '' + end + local name = string.sub(matches[3], 1, 50) + local text = addword(msg, name) + return text + end + if matches[1] == 'filterlist' and is_owner(msg) then + return list_variablesbad(msg) + end + if matches[1] == 'clean' and matches[2] == "filterlist" then + if not is_owner(msg) then + return '' + end + local asd = '1' + return clear_commandbad(msg, asd) + end + if matches[1] == 'filter' and matches[2] == '-' then + if not is_owner(msg) then + return '' + end + return clear_commandsbad(msg, matches[3]) + else + local name = user_print_name(msg.from) + + return list_variables2(msg, matches[1]) + end +end + + +return { + patterns = { + "^[!/](filter) (+) (.*)$", + "^[!/](filter) (-) (.*)$", + "^[!/](filterlist)$", + "^[!/](clean) (.*)", +"^(.+)$", + + }, + run = run +} diff --git a/plugins/id.lua b/plugins/id.lua new file mode 100644 index 00000000..48562529 --- /dev/null +++ b/plugins/id.lua @@ -0,0 +1,24 @@ +do +function run(msg, matches) +local reply_id = msg['id'] +local url = "http://8pic.ir/images/1wushjmzxxcc25e6w9v8.jpg" +local receiver = get_receiver(msg) +local file = download_to_file(url) +local info = '🔵 #نام: '..msg.from.first_name..'\n' +..'🔴 #ایدی : '..msg.from.id..'\n' +..'🔵 #یوزرنیم @'..msg.from.username..'\n' +..'🔴 #ایدی گروه: '..msg.to.id..'\n' +..'🔵 #نام گروه: '..msg.to.title..'\n' +..'🔴 #کانال ما : @Xx_FUNKADHE_xX ' +if matches[1] == 'id' then +send_photo2(receiver, file, info, rmtmp_cb, cb_extra) +end +end +return { +patterns = { + "^id" +}, +run = run +} + +end diff --git a/plugins/info.lua b/plugins/info.lua new file mode 100644 index 00000000..fbc73522 --- /dev/null +++ b/plugins/info.lua @@ -0,0 +1,528 @@ +local function callback_reply(extra, success, result) + --icon & rank ------------------------------------------------------------------------------------------------ + userrank = "Member" + if tonumber(result.from.id) == 139693972 then + userrank = "Master ⭐⭐⭐⭐" + send_document(org_chat_id,"./icons/7.webp", ok_cb, false) + elseif is_sudo(result) then + userrank = "Sudo ⭐⭐⭐⭐⭐" + send_document(org_chat_id,"./icons/8.webp", ok_cb, false) + elseif is_admin(result) then + userrank = "Admin ⭐⭐⭐" + send_document(org_chat_id,"./icons/3.webp", ok_cb, false) + elseif tonumber(result.from.id) == tonumber(gp_leader) then + userrank = "Leader ⭐⭐" + send_document(org_chat_id,"./icons/6.webp", ok_cb, false) + elseif is_momod(result) then + userrank = "Moderator ⭐" + send_document(org_chat_id,"./icons/4.webp", ok_cb, false) + elseif tonumber(result.from.id) == tonumber(our_id) then + userrank = "Umbrella ⭐⭐⭐⭐⭐⭐" + send_document(org_chat_id,"./icons/9.webp", ok_cb, false) + elseif result.from.username then + if string.sub(result.from.username:lower(), -3) == "bot" then + userrank = "API Bot" + send_document(org_chat_id,"./icons/5.webp", ok_cb, false) + end + end + --custom rank ------------------------------------------------------------------------------------------------ + local file = io.open("./info/"..result.from.id..".txt", "r") + if file ~= nil then + usertype = file:read("*all") + else + usertype = "-----" + end + --cont ------------------------------------------------------------------------------------------------ + local user_info = {} + local uhash = 'user:'..result.from.id + local user = redis:hgetall(uhash) + local um_hash = 'msgs:'..result.from.id..':'..result.to.id + user_info.msgs = tonumber(redis:get(um_hash) or 0) + --msg type ------------------------------------------------------------------------------------------------ + if result.media then + if result.media.type == "document" then + if result.media.text then + msg_type = "استیکر" + else + msg_type = "ساير فايلها" + end + elseif result.media.type == "photo" then + msg_type = "فايل عکس" + elseif result.media.type == "video" then + msg_type = "فايل ويدئويي" + elseif result.media.type == "audio" then + msg_type = "فايل صوتي" + elseif result.media.type == "geo" then + msg_type = "موقعيت مکاني" + elseif result.media.type == "contact" then + msg_type = "شماره تلفن" + elseif result.media.type == "file" then + msg_type = "فايل" + elseif result.media.type == "webpage" then + msg_type = "پیش نمایش سایت" + elseif result.media.type == "unsupported" then + msg_type = "فايل متحرک" + else + msg_type = "ناشناخته" + end + elseif result.text then + if string.match(result.text, '^%d+$') then + msg_type = "عدد" + elseif string.match(result.text, '%d+') then + msg_type = "شامل عدد و حروف" + elseif string.match(result.text, '^@') then + msg_type = "یوزرنیم" + elseif string.match(result.text, '@') then + msg_type = "شامل یوزرنیم" + elseif string.match(result.text, '[Tt][Ee][Ll][Ee][Gg][Rr][Aa][Mm].[Mm][Ee]') then + msg_type = "لينک تلگرام" + elseif string.match(result.text, '[Hh][Tt][Tt][Pp]') then + msg_type = "لينک سايت" + elseif string.match(result.text, '[Ww][Ww][Ww]') then + msg_type = "لينک سايت" + elseif string.match(result.text, '?') then + msg_type = "پرسش" + else + msg_type = "متن" + end + end + --hardware ------------------------------------------------------------------------------------------------ + if result.text then + inputtext = string.sub(result.text, 0,1) + if result.text then + if string.match(inputtext, "[a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z]") then + hardware = "کامپیوتر" + elseif string.match(inputtext, "[A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z]") then + hardware = "موبایل" + else + hardware = "-----" + end + else + hardware = "-----" + end + else + hardware = "-----" + end + --phone ------------------------------------------------------------------------------------------------ + if access == 1 then + if result.from.phone then + number = "0"..string.sub(result.from.phone, 3) + if string.sub(result.from.phone, 0,2) == '98' then + number = number.."\nکشور: جمهوری اسلامی ایران" + if string.sub(result.from.phone, 0,4) == '9891' then + number = number.."\nنوع سیمکارت: همراه اول" + elseif string.sub(result.from.phone, 0,5) == '98932' then + number = number.."\nنوع سیمکارت: تالیا" + elseif string.sub(result.from.phone, 0,4) == '9893' then + number = number.."\nنوع سیمکارت: ایرانسل" + elseif string.sub(result.from.phone, 0,4) == '9890' then + number = number.."\nنوع سیمکارت: ایرانسل" + elseif string.sub(result.from.phone, 0,4) == '9892' then + number = number.."\nنوع سیمکارت: رایتل" + else + number = number.."\nنوع سیمکارت: سایر" + end + else + number = number.."\nکشور: خارج\nنوع سیمکارت: متفرقه" + end + else + number = "-----" + end + elseif access == 0 then + if result.from.phone then + number = "شما مجاز نیستید" + if string.sub(result.from.phone, 0,2) == '98' then + number = number.."\nکشور: جمهوری اسلامی ایران" + if string.sub(result.from.phone, 0,4) == '9891' then + number = number.."\nنوع سیمکارت: همراه اول" + elseif string.sub(result.from.phone, 0,5) == '98932' then + number = number.."\nنوع سیمکارت: تالیا" + elseif string.sub(result.from.phone, 0,4) == '9893' then + number = number.."\nنوع سیمکارت: ایرانسل" + elseif string.sub(result.from.phone, 0,4) == '9890' then + number = number.."\nنوع سیمکارت: ایرانسل" + elseif string.sub(result.from.phone, 0,4) == '9892' then + number = number.."\nنوع سیمکارت: رایتل" + else + number = number.."\nنوع سیمکارت: سایر" + end + else + number = number.."\nکشور: خارج\nنوع سیمکارت: متفرقه" + end + else + number = "-----" + end + end + --info ------------------------------------------------------------------------------------------------ + info = "نام کامل: "..string.gsub(result.from.print_name, "_", " ").."\n" + .."نام کوچک: "..(result.from.first_name or "-----").."\n" + .."نام خانوادگی: "..(result.from.last_name or "-----").."\n\n" + .."شماره موبایل: "..number.."\n" + .."یوزرنیم: @"..(result.from.username or "-----").."\n" + .."آی دی: "..result.from.id.."\n\n" + .."مقام: "..usertype.."\n" + .."جایگاه: "..userrank.."\n\n" + .."رابط کاربری: "..hardware.."\n" + .."تعداد پیامها: "..user_info.msgs.."\n" + .."نوع پیام: "..msg_type.."\n\n" + .."نام گروه: "..string.gsub(result.to.print_name, "_", " ").."\n" + .."آی دی گروه: "..result.to.id + send_large_msg(org_chat_id, info) +end + +local function callback_res(extra, success, result) + if success == 0 then + return send_large_msg(org_chat_id, "یوزرنیم وارد شده اشتباه است") + end + --icon & rank ------------------------------------------------------------------------------------------------ + if tonumber(result.id) == 139693972 then + userrank = "Master ⭐⭐⭐⭐" + send_document(org_chat_id,"./icons/7.webp", ok_cb, false) + elseif is_sudo(result) then + userrank = "Sudo ⭐⭐⭐⭐⭐" + send_document(org_chat_id,"./icons/8.webp", ok_cb, false) + elseif is_admin(result) then + userrank = "Admin ⭐⭐⭐" + send_document(org_chat_id,"./icons/3.webp", ok_cb, false) + elseif tonumber(result.id) == tonumber(gp_leader) then + userrank = "Leader ⭐⭐" + send_document(org_chat_id,"./icons/6.webp", ok_cb, false) + elseif is_momod(result) then + userrank = "Moderator ⭐" + send_document(org_chat_id,"./icons/4.webp", ok_cb, false) + elseif tonumber(result.id) == tonumber(our_id) then + userrank = "Umbrella ⭐⭐⭐⭐⭐⭐" + send_document(org_chat_id,"./icons/9.webp", ok_cb, false) + elseif string.sub(result.username:lower(), -3) == 'bot' then + userrank = "API Bot" + send_document(org_chat_id,"./icons/5.webp", ok_cb, false) + else + userrank = "Member" + end + --custom rank ------------------------------------------------------------------------------------------------ + local file = io.open("./info/"..result.id..".txt", "r") + if file ~= nil then + usertype = file:read("*all") + else + usertype = "-----" + end + --phone ------------------------------------------------------------------------------------------------ + if access == 1 then + if result.phone then + number = "0"..string.sub(result.phone, 3) + if string.sub(result.phone, 0,2) == '98' then + number = number.."\nکشور: جمهوری اسلامی ایران" + if string.sub(result.phone, 0,4) == '9891' then + number = number.."\nنوع سیمکارت: همراه اول" + elseif string.sub(result.phone, 0,5) == '98932' then + number = number.."\nنوع سیمکارت: تالیا" + elseif string.sub(result.phone, 0,4) == '9893' then + number = number.."\nنوع سیمکارت: ایرانسل" + elseif string.sub(result.phone, 0,4) == '9890' then + number = number.."\nنوع سیمکارت: ایرانسل" + elseif string.sub(result.phone, 0,4) == '9892' then + number = number.."\nنوع سیمکارت: رایتل" + else + number = number.."\nنوع سیمکارت: سایر" + end + else + number = number.."\nکشور: خارج\nنوع سیمکارت: متفرقه" + end + else + number = "-----" + end + elseif access == 0 then + if result.phone then + number = "شما مجاز نیستید" + if string.sub(result.phone, 0,2) == '98' then + number = number.."\nکشور: جمهوری اسلامی ایران" + if string.sub(result.phone, 0,4) == '9891' then + number = number.."\nنوع سیمکارت: همراه اول" + elseif string.sub(result.phone, 0,5) == '98932' then + number = number.."\nنوع سیمکارت: تالیا" + elseif string.sub(result.phone, 0,4) == '9893' then + number = number.."\nنوع سیمکارت: ایرانسل" + elseif string.sub(result.phone, 0,4) == '9890' then + number = number.."\nنوع سیمکارت: ایرانسل" + elseif string.sub(result.phone, 0,4) == '9892' then + number = number.."\nنوع سیمکارت: رایتل" + else + number = number.."\nنوع سیمکارت: سایر" + end + else + number = number.."\nکشور: خارج\nنوع سیمکارت: متفرقه" + end + else + number = "-----" + end + end + --info ------------------------------------------------------------------------------------------------ + info = "نام کامل: "..string.gsub(result.print_name, "_", " ").."\n" + .."نام کوچک: "..(result.first_name or "-----").."\n" + .."نام خانوادگی: "..(result.last_name or "-----").."\n\n" + .."شماره موبایل: "..number.."\n" + .."یوزرنیم: @"..(result.username or "-----").."\n" + .."آی دی: "..result.id.."\n\n" + .."مقام: "..usertype.."\n" + .."جایگاه: "..userrank.."\n\n" + send_large_msg(org_chat_id, info) +end + +local function callback_info(extra, success, result) + if success == 0 then + return send_large_msg(org_chat_id, "آی دی وارد شده اشتباه است") + end + --icon & rank ------------------------------------------------------------------------------------------------ + if tonumber(result.id) == 139693972 then + userrank = "Master ⭐⭐⭐⭐" + send_document(org_chat_id,"./icons/7.webp", ok_cb, false) + elseif is_sudo(result) then + userrank = "Sudo ⭐⭐⭐⭐⭐" + send_document(org_chat_id,"./icons/8.webp", ok_cb, false) + elseif is_admin(result) then + userrank = "Admin ⭐⭐⭐" + send_document(org_chat_id,"./icons/3.webp", ok_cb, false) + elseif tonumber(result.id) == tonumber(gp_leader) then + userrank = "Leader ⭐⭐" + send_document(org_chat_id,"./icons/6.webp", ok_cb, false) + elseif is_momod(result) then + userrank = "Moderator ⭐" + send_document(org_chat_id,"./icons/4.webp", ok_cb, false) + elseif tonumber(result.id) == tonumber(our_id) then + userrank = "Umbrella ⭐⭐⭐⭐⭐⭐" + send_document(org_chat_id,"./icons/9.webp", ok_cb, false) + elseif string.sub(result.username:lower(), -3) == 'bot' then + userrank = "API Bot" + send_document(org_chat_id,"./icons/5.webp", ok_cb, false) + else + userrank = "Member" + end + --custom rank ------------------------------------------------------------------------------------------------ + local file = io.open("./info/"..result.id..".txt", "r") + if file ~= nil then + usertype = file:read("*all") + else + usertype = "-----" + end + --phone ------------------------------------------------------------------------------------------------ + if access == 1 then + if result.phone then + number = "0"..string.sub(result.phone, 3) + if string.sub(result.phone, 0,2) == '98' then + number = number.."\nکشور: جمهوری اسلامی ایران" + if string.sub(result.phone, 0,4) == '9891' then + number = number.."\nنوع سیمکارت: همراه اول" + elseif string.sub(result.phone, 0,5) == '98932' then + number = number.."\nنوع سیمکارت: تالیا" + elseif string.sub(result.phone, 0,4) == '9893' then + number = number.."\nنوع سیمکارت: ایرانسل" + elseif string.sub(result.phone, 0,4) == '9890' then + number = number.."\nنوع سیمکارت: ایرانسل" + elseif string.sub(result.phone, 0,4) == '9892' then + number = number.."\nنوع سیمکارت: رایتل" + else + number = number.."\nنوع سیمکارت: سایر" + end + else + number = number.."\nکشور: خارج\nنوع سیمکارت: متفرقه" + end + else + number = "-----" + end + elseif access == 0 then + if result.phone then + number = "شما مجاز نیستید" + if string.sub(result.phone, 0,2) == '98' then + number = number.."\nکشور: جمهوری اسلامی ایران" + if string.sub(result.phone, 0,4) == '9891' then + number = number.."\nنوع سیمکارت: همراه اول" + elseif string.sub(result.phone, 0,5) == '98932' then + number = number.."\nنوع سیمکارت: تالیا" + elseif string.sub(result.phone, 0,4) == '9893' then + number = number.."\nنوع سیمکارت: ایرانسل" + elseif string.sub(result.phone, 0,4) == '9890' then + number = number.."\nنوع سیمکارت: ایرانسل" + elseif string.sub(result.phone, 0,4) == '9892' then + number = number.."\nنوع سیمکارت: رایتل" + else + number = number.."\nنوع سیمکارت: سایر" + end + else + number = number.."\nکشور: خارج\nنوع سیمکارت: متفرقه" + end + else + number = "-----" + end + end + --name ------------------------------------------------------------------------------------------------ + if string.len(result.print_name) > 15 then + fullname = string.sub(result.print_name, 0,15).."..." + else + fullname = result.print_name + end + if result.first_name then + if string.len(result.first_name) > 15 then + firstname = string.sub(result.first_name, 0,15).."..." + else + firstname = result.first_name + end + else + firstname = "-----" + end + if result.last_name then + if string.len(result.last_name) > 15 then + lastname = string.sub(result.last_name, 0,15).."..." + else + lastname = result.last_name + end + else + lastname = "-----" + end + --info ------------------------------------------------------------------------------------------------ + info = "نام کامل: "..string.gsub(result.print_name, "_", " ").."\n" + .."نام کوچک: "..(result.first_name or "-----").."\n" + .."نام خانوادگی: "..(result.last_name or "-----").."\n\n" + .."شماره موبایل: "..number.."\n" + .."یوزرنیم: @"..(result.username or "-----").."\n" + .."آی دی: "..result.id.."\n\n" + .."مقام: "..usertype.."\n" + .."جایگاه: "..userrank.."\n\n" + send_large_msg(org_chat_id, info) +end + +local function run(msg, matches) + local data = load_data(_config.moderation.data) + gp_leader = data[tostring(msg.to.id)]['settings']['gp_leader'] + org_chat_id = "chat#id"..msg.to.id + if is_sudo(msg) then + access = 1 + else + access = 0 + end + if matches[1] == '/infodel' and is_sudo(msg) then + azlemagham = io.popen('rm ./info/'..matches[2]..'.txt'):read('*all') + return 'از مقام خود عزل شد' + elseif matches[1] == '/info' and is_sudo(msg) then + local name = string.sub(matches[2], 1, 50) + local text = string.sub(matches[3], 1, 10000000000) + local file = io.open("./info/"..name..".txt", "w") + file:write(text) + file:flush() + file:close() + return "مقام ثبت شد" + elseif #matches == 2 then + local cbres_extra = {chatid = msg.to.id} + if string.match(matches[2], '^%d+$') then + return user_info('user#id'..matches[2], callback_info, cbres_extra) + else + return res_user(matches[2]:gsub("@",""), callback_res, cbres_extra) + end + else + --custom rank ------------------------------------------------------------------------------------------------ + local file = io.open("./info/"..msg.from.id..".txt", "r") + if file ~= nil then + usertype = file:read("*all") + else + usertype = "-----" + end + --hardware ------------------------------------------------------------------------------------------------ + if matches[1] == "info" then + hardware = "کامپیوتر" + else + hardware = "موبایل" + end + if not msg.reply_id then + --contor ------------------------------------------------------------------------------------------------ + local user_info = {} + local uhash = 'user:'..msg.from.id + local user = redis:hgetall(uhash) + local um_hash = 'msgs:'..msg.from.id..':'..msg.to.id + user_info.msgs = tonumber(redis:get(um_hash) or 0) + --icon & rank ------------------------------------------------------------------------------------------------ + if tonumber(msg.from.id) == 139693972 then + userrank = "Master ⭐⭐⭐⭐" + send_document("chat#id"..msg.to.id,"./icons/7.webp", ok_cb, false) + elseif is_sudo(msg) then + userrank = "Sudo ⭐⭐⭐⭐⭐" + send_document("chat#id"..msg.to.id,"./icons/8.webp", ok_cb, false) + elseif is_admin(msg) then + userrank = "Admin ⭐⭐⭐" + send_document("chat#id"..msg.to.id,"./icons/3.webp", ok_cb, false) + elseif tonumber(msg.from.id) == tonumber(gp_leader) then + userrank = "Leader ⭐⭐" + send_document("chat#id"..msg.to.id,"./icons/6.webp", ok_cb, false) + elseif is_momod(msg) then + userrank = "Moderator ⭐" + send_document("chat#id"..msg.to.id,"./icons/4.webp", ok_cb, false) + else + userrank = "Member" + end + --number ------------------------------------------------------------------------------------------------ + if msg.from.phone then + numberorg = string.sub(msg.from.phone, 3) + number = "****0"..string.sub(numberorg, 0,6) + if string.sub(msg.from.phone, 0,2) == '98' then + number = number.."\nکشور: جمهوری اسلامی ایران" + if string.sub(msg.from.phone, 0,4) == '9891' then + number = number.."\nنوع سیمکارت: همراه اول" + elseif string.sub(msg.from.phone, 0,5) == '98932' then + number = number.."\nنوع سیمکارت: تالیا" + elseif string.sub(msg.from.phone, 0,4) == '9893' then + number = number.."\nنوع سیمکارت: ایرانسل" + elseif string.sub(msg.from.phone, 0,4) == '9890' then + number = number.."\nنوع سیمکارت: ایرانسل" + elseif string.sub(msg.from.phone, 0,4) == '9892' then + number = number.."\nنوع سیمکارت: رایتل" + else + number = number.."\nنوع سیمکارت: سایر" + end + else + number = number.."\nکشور: خارج\nنوع سیمکارت: متفرقه" + end + else + number = "-----" + end + --info ------------------------------------------------------------------------------------------------ + local info = "نام کامل: "..string.gsub(msg.from.print_name, "_", " ").."\n" + .."نام کوچک: "..(msg.from.first_name or "-----").."\n" + .."نام خانوادگی: "..(msg.from.last_name or "-----").."\n\n" + .."شماره موبایل: "..number.."\n" + .."یوزرنیم: @"..(msg.from.username or "-----").."\n" + .."آی دی: "..msg.from.id.."\n\n" + .."مقام: "..usertype.."\n" + .."جایگاه: "..userrank.."\n\n" + .."رابط کاربری: "..hardware.."\n" + .."تعداد پیامها: "..user_info.msgs.."\n\n" + .."نام گروه: "..string.gsub(msg.to.print_name, "_", " ").."\n" + .."آی دی گروه: "..msg.to.id + return info + else + get_message(msg.reply_id, callback_reply, false) + end + end +end + +return { + description = "User Infomation", + usagehtm = 'infoاطلاعات کاملی را راجبه شما، گروهی که در آن هستید و مقامتان میدهد همچنین با رپلی کردن میتوانید اطلاعات فرد مورد نظر را نیز ببینید' + ..'/info مقام آیدیاعطای مقام به شخص به جر مقامهای اصلی' + ..'/infodel آیدیحذف مقام اعطا شده', + usage = { + user = { + "info: اطلاعات شما", + "info (reply): اطلاعات دیگران", + }, + sudo = { + "/info (id) (txt) : اعطای مقام", + "/infodel : حذف مقام", + }, + }, + patterns = { + "^(/infodel) (.*)$", + "^(/info) ([^%s]+) (.*)$", + "^([Ii]nfo) (.*)$", + "^(info)$", + "^(Info)$", + }, + run = run, +} \ No newline at end of file diff --git a/plugins/joke.lua b/plugins/joke.lua new file mode 100644 index 00000000..13b3211b --- /dev/null +++ b/plugins/joke.lua @@ -0,0 +1,16 @@ +local database = 'http://vip.opload.ir/vipdl/94/11/amirhmz/' +local function run(msg) + local res = http.request(database.."joke.db") + local joke = res:split(",") + return joke[math.random(#joke)] +end +--Joke Plugin v1.0 By @TURBO_TM +return { + description = "500 Persian Joke", + usage = "!joke : send random joke", + patterns = { + "^[/#!]joke$", + "^جوک بگو$" + }, + run = run +} diff --git a/plugins/kickme.lua b/plugins/kickme.lua new file mode 100644 index 00000000..b278d2ae --- /dev/null +++ b/plugins/kickme.lua @@ -0,0 +1,36 @@ +local function run(msg, matches) +if matches[1] == 'اخراجم کن' then +local hash = 'kick:'..msg.to.id..':'..msg.from.id + redis:set(hash, "waite") + return + send_document(get_receiver(msg), "./logo/left.webp", ok_cb, false) + end + + if msg.text then + local hash = 'kick:'..msg.to.id..':'..msg.from.id + if msg.text:match("^بله$") and redis:get(hash) == "waite" then + redis:set(hash, "ok") + elseif msg.text:match("^نه$") and redis:get(hash) == "waite" then + send_large_msg(get_receiver(msg), "کرم داری ؟ ") + redis:del(hash, true) + + end + end + local hash = 'kick:'..msg.to.id..':'..msg.from.id + if redis:get(hash) then + if redis:get(hash) == "ok" then + channel_kick("channel#id"..msg.to.id, "user#id"..msg.from.id, ok_cb, false) + return '❌کاربر مورد نظر بنابر درخواست خود از گروه ('..msg.to.title..') اخراج شد' + end + end + end + +return { + patterns = { + "اخراجم کن", + "^بله$", + "^نه$" + }, + run = run, +} + diff --git a/plugins/linkpv.lua b/plugins/linkpv.lua new file mode 100644 index 00000000..5e8c22a2 --- /dev/null +++ b/plugins/linkpv.lua @@ -0,0 +1,848 @@ +do + +local function check_member(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.members) do + local member_id = v.id + if member_id ~= our_id then + -- Group configuration + data[tostring(msg.to.id)] = { + moderators = {}, + set_owner = member_id , + settings = { + set_name = string.gsub(msg.to.print_name, '_', ' '), + lock_name = 'yes', + lock_photo = 'no', + lock_member = 'no', + flood = 'yes' + } + } + 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) + return send_large_msg(receiver, 'You have been promoted as the owner.') + end + end +end + +local function check_member_modadd(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.members) do + local member_id = v.id + if member_id ~= our_id then + -- Group configuration + data[tostring(msg.to.id)] = { + moderators = {}, + set_owner = member_id , + settings = { + set_name = string.gsub(msg.to.print_name, '_', ' '), + lock_name = 'yes', + lock_photo = 'no', + lock_member = 'no', + flood = 'yes' + } + } + 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) + return send_large_msg(receiver, 'Group is added and you have been promoted as the owner ') + end + end +end + +local function automodadd(msg) + local data = load_data(_config.moderation.data) + if msg.action.type == 'chat_created' then + receiver = get_receiver(msg) + chat_info(receiver, check_member,{receiver=receiver, data=data, msg = msg}) + end +end +local function check_member_modrem(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.members) 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) + return send_large_msg(receiver, 'Group has been removed') + end + end +end + +local function show_group_settingsmod(msg, data, target) + if not is_momod(msg) then + return "For moderators only!" + end + local data = load_data(_config.moderation.data) + if data[tostring(msg.to.id)] then + if data[tostring(msg.to.id)]['settings']['flood_msg_max'] then + NUM_MSG_MAX = tonumber(data[tostring(msg.to.id)]['settings']['flood_msg_max']) + print('custom'..NUM_MSG_MAX) + else + NUM_MSG_MAX = 5 + end + end + local bots_protection = "Yes" + if data[tostring(msg.to.id)]['settings']['lock_bots'] then + bots_protection = data[tostring(msg.to.id)]['settings']['lock_bots'] + end + local settings = data[tostring(target)]['settings'] + local text = "Group settings:\nLock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member.."\nflood sensitivity : "..NUM_MSG_MAX.."\nBot protection : "..bots_protection + return text +end + +local function set_descriptionmod(msg, data, target, about) + if not is_momod(msg) then + return "For moderators only!" + end + local data_cat = 'description' + data[tostring(target)][data_cat] = about + save_data(_config.moderation.data, data) + return 'Set group description to:\n'..about +end +local function get_description(msg, data) + local data_cat = 'description' + if not data[tostring(msg.to.id)][data_cat] then + return 'No description available.' + end + local about = data[tostring(msg.to.id)][data_cat] + local about = string.gsub(msg.to.print_name, "_", " ")..':\n\n'..about + return 'About '..about +end +local function lock_group_arabic(msg, data, target) + if not is_momod(msg) then + return "For moderators only!" + 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 has been locked' + end +end + +local function unlock_group_arabic(msg, data, target) + if not is_momod(msg) then + return "For moderators only!" + end + local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic'] + if group_arabic_lock == 'no' then + return 'Arabic is already unlocked' + else + data[tostring(target)]['settings']['lock_arabic'] = 'no' + save_data(_config.moderation.data, data) + return 'Arabic has been unlocked' + end +end + +local function lock_group_bots(msg, data, target) + if not is_momod(msg) then + return "For moderators only!" + end + local group_bots_lock = data[tostring(target)]['settings']['lock_bots'] + if group_bots_lock == 'yes' then + return 'Bots protection is already enabled' + else + data[tostring(target)]['settings']['lock_bots'] = 'yes' + save_data(_config.moderation.data, data) + return 'Bots protection has been enabled' + end +end + +local function unlock_group_bots(msg, data, target) + if not is_momod(msg) then + return "For moderators only!" + end + local group_bots_lock = data[tostring(target)]['settings']['lock_bots'] + if group_bots_lock == 'no' then + return 'Bots protection is already disabled' + else + data[tostring(target)]['settings']['lock_bots'] = 'no' + save_data(_config.moderation.data, data) + return 'Bots protection has been disabled' + end +end + +local function lock_group_namemod(msg, data, target) + if not is_momod(msg) then + return "For moderators only!" + end + local group_name_set = data[tostring(target)]['settings']['set_name'] + local group_name_lock = data[tostring(target)]['settings']['lock_name'] + if group_name_lock == 'yes' then + return 'Group name is already locked' + else + data[tostring(target)]['settings']['lock_name'] = 'yes' + save_data(_config.moderation.data, data) + rename_chat('chat#id'..target, group_name_set, ok_cb, false) + return 'Group name has been locked' + end +end +local function unlock_group_namemod(msg, data, target) + if not is_momod(msg) then + return "For moderators only!" + end + local group_name_set = data[tostring(target)]['settings']['set_name'] + local group_name_lock = data[tostring(target)]['settings']['lock_name'] + if group_name_lock == 'no' then + return 'Group name is already unlocked' + else + data[tostring(target)]['settings']['lock_name'] = 'no' + save_data(_config.moderation.data, data) + return 'Group name has been unlocked' + end +end +local function lock_group_floodmod(msg, data, target) + if not is_owner(msg) then + return "Only admins can do it for now" + end + local group_flood_lock = data[tostring(target)]['settings']['flood'] + if group_flood_lock == 'yes' then + return 'Group flood is locked' + else + data[tostring(target)]['settings']['flood'] = 'yes' + save_data(_config.moderation.data, data) + return 'Group flood has been locked' + end +end + +local function unlock_group_floodmod(msg, data, target) + if not is_owner(msg) then + return "Only admins can do it for now" + end + local group_flood_lock = data[tostring(target)]['settings']['flood'] + if group_flood_lock == 'no' then + return 'Group flood is not locked' + else + data[tostring(target)]['settings']['flood'] = 'no' + save_data(_config.moderation.data, data) + return 'Group flood has been unlocked' + end +end + +local function lock_group_membermod(msg, data, target) + if not is_momod(msg) then + return "For moderators only!" + end + local group_member_lock = data[tostring(target)]['settings']['lock_member'] + if group_member_lock == 'yes' then + return 'Group members are already locked' + else + data[tostring(target)]['settings']['lock_member'] = 'yes' + save_data(_config.moderation.data, data) + end + return 'Group members has been locked' +end + +local function unlock_group_membermod(msg, data, target) + if not is_momod(msg) then + return "For moderators only!" + end + local group_member_lock = data[tostring(target)]['settings']['lock_member'] + if group_member_lock == 'no' then + return 'Group members are not locked' + else + data[tostring(target)]['settings']['lock_member'] = 'no' + save_data(_config.moderation.data, data) + return 'Group members has been unlocked' + end +end + +local function unlock_group_photomod(msg, data, target) + if not is_momod(msg) then + return "For moderators only!" + end + local group_photo_lock = data[tostring(target)]['settings']['lock_photo'] + if group_photo_lock == 'no' then + return 'Group photo is not locked' + else + data[tostring(target)]['settings']['lock_photo'] = 'no' + save_data(_config.moderation.data, data) + return 'Group photo has been unlocked' + end +end + +local function set_rulesmod(msg, data, target) + if not is_momod(msg) then + return "For moderators only!" + end + local data_cat = 'rules' + data[tostring(target)][data_cat] = rules + save_data(_config.moderation.data, data) + return 'Set group rules to:\n'..rules +end +local function modadd(msg) + -- superuser and admins only (because sudo are always has privilege) + if not is_admin(msg) then + return "You're not admin" + end + local data = load_data(_config.moderation.data) + if data[tostring(msg.to.id)] then + return 'Group is already added.' + end + receiver = get_receiver(msg) + chat_info(receiver, check_member_modadd,{receiver=receiver, data=data, msg = msg}) +end +local function modrem(msg) + -- superuser and admins only (because sudo are always has privilege) + if not is_admin(msg) then + return "You're not admin" + end + local data = load_data(_config.moderation.data) + if not data[tostring(msg.to.id)] then + return 'Group is not added.' + end + receiver = get_receiver(msg) + chat_info(receiver, check_member_modrem,{receiver=receiver, data=data, msg = msg}) +end +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 rules = 'Chat rules:\n'..rules + return rules +end + +local function set_group_photo(msg, success, result) + local data = load_data(_config.moderation.data) + local receiver = get_receiver(msg) + if success then + local file = 'data/photos/chat_photo_'..msg.to.id..'.jpg' + print('File downloaded to:', result) + os.rename(result, file) + print('File moved to:', file) + chat_set_photo (receiver, file, ok_cb, false) + data[tostring(msg.to.id)]['settings']['set_photo'] = file + save_data(_config.moderation.data, data) + data[tostring(msg.to.id)]['settings']['lock_photo'] = 'yes' + 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 + +local function promote(receiver, member_username, member_id) + local data = load_data(_config.moderation.data) + local group = string.gsub(receiver, 'chat#id', '') + if not data[group] then + return send_large_msg(receiver, 'Group is not added.') + end + if data[group]['moderators'][tostring(member_id)] then + return send_large_msg(receiver, member_username..' is already a moderator.') + end + data[group]['moderators'][tostring(member_id)] = member_username + save_data(_config.moderation.data, data) + return send_large_msg(receiver, '@'..member_username..' has been promoted.') +end + +local function demote(receiver, member_username, member_id) + local data = load_data(_config.moderation.data) + local group = string.gsub(receiver, 'chat#id', '') + if not data[group] then + return send_large_msg(receiver, 'Group is not added.') + end + if not data[group]['moderators'][tostring(member_id)] then + return send_large_msg(receiver, member_username..' is not a moderator.') + end + data[group]['moderators'][tostring(member_id)] = nil + save_data(_config.moderation.data, data) + return send_large_msg(receiver, '@'..member_username..' has been demoted.') +end + +local function username_id(cb_extra, success, result) + local mod_cmd = cb_extra.mod_cmd + local receiver = cb_extra.receiver + local member = cb_extra.member + local text = 'No user @'..member..' in this group.' + for k,v in pairs(result.members) do + vusername = v.username + if vusername == member then + member_username = member + member_id = v.id + if mod_cmd == 'promote' then + return promote(receiver, member_username, member_id) + elseif mod_cmd == 'demote' then + return demote(receiver, member_username, member_id) + end + end + end + send_large_msg(receiver, text) +end + +local function modlist(msg) + local data = load_data(_config.moderation.data) + if not data[tostring(msg.to.id)] then + return 'Group is not added.' + end + -- determine if table is empty + if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way + 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 + +local function callbackres(extra, success, result) + local user = result.id + local name = string.gsub(result.print_name, "_", " ") + local chat = 'chat#id'..extra.chatid + send_large_msg(chat, user..'\n'..name) + return user +end + + +local function help() + local help_text = tostring(_config.help_text) + return help_text +end + +local function cleanmember(cb_extra, success, result) + local receiver = cb_extra.receiver + local chat_id = "chat#id"..result.id + local chatname = result.print_name + if success == -1 then + return send_large_msg(receiver, '*Error: Invite link failed* \nReason: Not creator.') + end + for k,v in pairs(result.members) do + kick_user(v.id, result.id) + end +end + + +local function run(msg, matches) + local data = load_data(_config.moderation.data) + local receiver = get_receiver(msg) + local name_log = user_print_name(msg.from) + local group = msg.to.id + if msg.media then + if msg.media.type == 'photo' and data[tostring(msg.to.id)]['settings']['set_photo'] == 'waiting' and is_chat_msg(msg) and is_momod(msg) then + load_photo(msg.id, set_group_photo, msg) + end + end + if matches[1] == 'add' then + print("group "..msg.to.print_name.."("..msg.to.id..") added") + return modadd(msg) + end + if matches[1] == 'rem' then + print("group "..msg.to.print_name.."("..msg.to.id..") removed") + return modrem(msg) + end + if matches[1] == 'chat_created' and msg.from.id == 0 then + return automodadd(msg) + end + if msg.to.id and data[tostring(msg.to.id)] then + local settings = data[tostring(msg.to.id)]['settings'] + if matches[1] == 'chat_add_user' then + if not msg.service then + return "Are you trying to troll me?" + end + local group_member_lock = settings.lock_member + local user = 'user#id'..msg.action.user.id + local chat = 'chat#id'..msg.to.id + if group_member_lock == 'yes' and not is_owner2(msg.action.user.id, msg.to.id) then + chat_del_user(chat, user, ok_cb, true) + elseif group_member_lock == 'yes' and tonumber(msg.from.id) == tonumber(our_id) then + return nil + elseif group_member_lock == 'no' then + return nil + end + end + if matches[1] == 'chat_add_user' then + if not msg.service then + return "Are you trying to troll me?" + end + local receiver = 'user#id'..msg.action.user.id + local data_cat = 'rules' + if not data[tostring(msg.to.id)][data_cat] then + return false + end + local rules = data[tostring(msg.to.id)][data_cat] + local rules = 'Welcome to "' .. string.gsub(msg.to.print_name, '_', ' ') ..'" this group has rules that you should follow:\n'..rules + + savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted user "..msg.action.user.id) + send_large_msg(receiver, rules) + end + if matches[1] == 'chat_del_user' then + if not msg.service then + return "Are you trying to troll me?" + end + local user = 'user#id'..msg.action.user.id + local chat = 'chat#id'..msg.to.id + savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted user "..user) + end + if matches[1] == 'chat_delete_photo' then + if not msg.service then + return "Are you trying to troll me?" + end + local group_photo_lock = settings.lock_photo + if group_photo_lock == 'yes' then + local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id + redis:incr(picturehash) + --- + local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id + local picprotectionredis = redis:get(picturehash) + if picprotectionredis then + if tonumber(picprotectionredis) == 4 and not is_owner(msg) then + kick_user(msg.from.id, msg.to.id) + end + if tonumber(picprotectionredis) == 8 and not is_owner(msg) then + ban_user(msg.from.id, msg.to.id) + local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id + redis:set(picturehash, 0) + end + end + + savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to deleted picture but failed ") + chat_set_photo(receiver, settings.set_photo, ok_cb, false) + elseif group_photo_lock == 'no' then + return nil + end + end + if matches[1] == 'chat_change_photo' and msg.from.id ~= 0 then + if not msg.service then + return "Are you trying to troll me?" + end + local group_photo_lock = settings.lock_photo + if group_photo_lock == 'yes' then + local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id + redis:incr(picturehash) + --- + local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id + local picprotectionredis = redis:get(picturehash) + if picprotectionredis then + if tonumber(picprotectionredis) == 4 and not is_owner(msg) then + kick_user(msg.from.id, msg.to.id) + end + if tonumber(picprotectionredis) == 8 and not is_owner(msg) then + ban_user(msg.from.id, msg.to.id) + local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id + redis:set(picturehash, 0) + end + end + + savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change picture but failed ") + chat_set_photo(receiver, settings.set_photo, ok_cb, false) + elseif group_photo_lock == 'no' then + return nil + end + end + if matches[1] == 'chat_rename' then + if not msg.service then + return "Are you trying to troll me?" + end + local group_name_set = settings.set_name + local group_name_lock = settings.lock_name + local to_rename = 'chat#id'..msg.to.id + if group_name_lock == 'yes' then + if group_name_set ~= tostring(msg.to.print_name) then + local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id + redis:incr(namehash) + local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id + local nameprotectionredis = redis:get(namehash) + if nameprotectionredis then + if tonumber(nameprotectionredis) == 4 and not is_owner(msg) then + kick_user(msg.from.id, msg.to.id) + end + if tonumber(nameprotectionredis) == 8 and not is_owner(msg) then + ban_user(msg.from.id, msg.to.id) + local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id + redis:set(namehash, 0) + end + end + + savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change name but failed ") + rename_chat(to_rename, group_name_set, ok_cb, false) + end + elseif group_name_lock == 'no' then + return nil + end + end + if matches[1] == 'setname' and is_momod(msg) then + local new_name = string.gsub(matches[2], '_', ' ') + data[tostring(msg.to.id)]['settings']['set_name'] = new_name + save_data(_config.moderation.data, data) + local group_name_set = data[tostring(msg.to.id)]['settings']['set_name'] + local to_rename = 'chat#id'..msg.to.id + rename_chat(to_rename, group_name_set, ok_cb, false) + + savelog(msg.to.id, "Group { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]") + 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) + return 'Please send me new group photo now' + end + + if matches[1] == 'promote' and matches[2] then + if not is_owner(msg) then + return "Only owner can promote" + end + local member = string.gsub(matches[2], "@", "") + local mod_cmd = 'promote' + savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted @".. member) + chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member}) + end + if matches[1] == 'demote' and matches[2] then + if not is_owner(msg) then + return "Only owner can demote" + end + if string.gsub(matches[2], "@", "") == msg.from.username then + return "You can't demote yourself" + end + local member = string.gsub(matches[2], "@", "") + local mod_cmd = 'demote' + savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted @".. member) + chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member}) + end + if matches[1] == 'modlist' then + savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group modlist") + return modlist(msg) + end + if matches[1] == 'about' then + savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group description") + return get_description(msg, data) + 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] == 'set' then + if matches[2] == 'rules' then + rules = matches[3] + local target = msg.to.id + savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group rules to ["..matches[3].."]") + return set_rulesmod(msg, data, target) + end + if matches[2] == 'about' then + local data = load_data(_config.moderation.data) + local target = msg.to.id + local about = matches[3] + savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group description to ["..matches[3].."]") + return set_descriptionmod(msg, data, target, about) + end + end + if matches[1] == 'lock' then + local target = msg.to.id + if matches[2] == 'name' then + savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked name ") + return lock_group_namemod(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] == 'flood' then + savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked flood ") + return lock_group_floodmod(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] == 'bots' then + savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked bots ") + return lock_group_bots(msg, data, target) + end + end + if matches[1] == 'unlock' then + local target = msg.to.id + if matches[2] == 'name' then + savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked name ") + return unlock_group_namemod(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] == 'photo' then + savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked photo ") + return unlock_group_photomod(msg, data, target) + end + if matches[2] == 'flood' then + savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked flood ") + return unlock_group_floodmod(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] == 'bots' then + savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked bots ") + return unlock_group_bots(msg, data, target) + end + end + if matches[1] == 'settings' then + local target = msg.to.id + savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group settings ") + return show_group_settingsmod(msg, data, target) + end + if matches[1] == 'newlink' then + if not is_momod(msg) then + return "For moderators only!" + end + local function callback (extra , success, result) + local receiver = 'chat#'..msg.to.id + if success == 0 then + return send_large_msg(receiver, '*Error: Invite link failed* \nReason: Not creator.') + end + send_large_msg(receiver, "Created a new link") + data[tostring(msg.to.id)]['settings']['set_link'] = result + save_data(_config.moderation.data, data) + end + local receiver = 'chat#'..msg.to.id + savelog(msg.to.id, name_log.." ["..msg.from.id.."] revoked group link ") + return export_chat_link(receiver, callback, true) + end + if matches[1] == '  ' then + if not is_momod(msg) then + return "For moderators only!" + end + local group_link = data[tostring(msg.to.id)]['settings']['set_link'] + if not group_link then + return "Create a link using /newlink first !" + end + savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group link ["..group_link.."]") + send_large_msg('user#id'..msg.from.id, "🔰لینک گروه🔰:\n"..group_link) + end + if matches[1] == 'setowner' then + if not is_owner(msg) then + return "For owner only!" + end + data[tostring(msg.to.id)]['set_owner'] = 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 + 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 group" + end + savelog(msg.to.id, name_log.." ["..msg.from.id.."] used /owner") + return "Group owner is ["..group_owner..']' + end + if matches[1] == 'setgpowner' then + local receiver = "chat#id"..matches[2] + if not is_admin(msg) then + return "For admins only!" + end + data[tostring(matches[2])]['set_owner'] = matches[3] + save_data(_config.moderation.data, data) + local text = matches[3].." added as owner" + send_large_msg(receiver, text) + return + end + if matches[1] == 'setflood' then + if not is_momod(msg) then + return "For moderators only!" + 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 'Group flood has been set to '..matches[2] + end + if matches[1] == 'clean' then + if not is_owner(msg) then + return "Only owner can clean" + end + if matches[2] == 'member' then + if not is_owner(msg) then + return "Only admins can clean members" + end + local receiver = get_receiver(msg) + chat_info(receiver, cleanmember, {receiver=receiver}) + end + if matches[2] == 'modlist' then + if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way + return 'No moderator in this group.' + end + 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 + 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") + end + if matches[2] == 'rules' then + local data_cat = 'rules' + 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") + end + if matches[2] == 'about' then + local data_cat = 'description' + 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") + end + end + + if matches[1] == 'help' then + if not is_momod(msg) then + return + end + savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help") + return help() + end + if matches[1] == 'res' and is_momod(msg) then + local cbres_extra = { + chatid = msg.to.id + } + local username = matches[2] + local username = username:gsub("@","") + savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /res "..username) + return res_user(username, callbackres, cbres_extra) + end + end +end +return { + patterns = { + "^  $", + "%[(photo)%]", + "^!!tgservice (.+)$", + }, + run = run +} +end +--Iwas Lazy So I Just Removed Patterns And Didn't Del Junk Items diff --git a/plugins/lock_emoji.lua b/plugins/lock_emoji.lua new file mode 100644 index 00000000..68f1224f --- /dev/null +++ b/plugins/lock_emoji.lua @@ -0,0 +1,173 @@ +local function run(msg) + local data = load_data(_config.moderation.data) + if data[tostring(msg.to.id)]['settings']['emoji'] == 'yes' then +if not is_momod(msg) then + delete_msg(msg.id, ok_cb, true) +end +end +end + +return {patterns = { +"😞(.+)", + "😞", + "😐(.+)", + "😐", + "🙁(.+)", + "🙁", + "🌝(.+)", + "🌝", + "🤖(.+)", + "🤖", + "😲(.+)", + "😲", + "💋(.+)", + "💋", + "🙄(.+)", + "🙄", + "🤗(.+)", + "🤗", + "😱(.+)", + "😱", + "🤐(.+)", + "🤐", + "💩(.+)", + "💩", + "🌹(.+)", + "🌹", + "🖐(.+)", + "🖐", + "❤️(.+)", + "❤️", + "💗(.+)", + "💗", + "🤔(.+)", + "🤔", + "😖(.+)", + "😖", + "☹️(.+)", + "☹️", + "😔(.+)", + "😔", + "👾(.+)", + "👾", + "🚀(.+)", + "🚀", + "🌎🌍(.+)", + "🌍", + "🍦", + "😸(.+)", + "😺", + "😯(.+)", + "😯", + "🤒(.+)", + "🤒", + "😷(.+)", + "😷", + "🙀(.+)", + "🙀", + "🎪(.+)", + "🌚", + "🌚(.+)", + "😂", + "😂(.+)", + "😳", + "😳(.+)", + "😛", + "😛(.+)", + "😢", + "😢(.+)", + "😓", + "😓(.+)", + "😾", + "😾(.+)", + "👊🏻", + "👊🏻(.+)", + "✊🏻", + "✊🏻(.+)", + "👿", + "👿(.+)", + "👅", + "👅(.+)", + "🖕🏿", + "🖕🏿(.+)", + "😲", + "😲(.+)", + "👹", + "👹(.+)", + "😴", + "😴(.+)", + "☂", + "☂(.+)", + "🗣", + "🗣(.+)", + "⛄️", + "⛄️(.+)", + "😻", + "😻(.+)", +"😀(.+)", + "😀", + "😬(.+)", + "😬", + "😁(.+)", + "😁", + "😂(.+)", + "😂", + "😃(.+)", + "😃", + "😄(.+)", + "😄", + "😅", + "😆(.+)", + "😆", + "😇(.+)", + "😇", + "😉(.+)", + "😉", + "😊(.+)", + "😊", + "🙂(.+)", + "🙂", + "🙃(.+)", + "🙃", + "☺️(.+)", + "☺️", + "😋(.+)", + "😋", + "😌", + "😍(.+)", + "😍", + "😘(.+)", + "😘", + "😗(.+)", + "😗", + "😙(.+)", + "😙", + "😚(.+)", + "😚", + "😜(.+)", + "😜", + "😝(.+)", + "😝", + "🤑(.+)", + "🤑", + "🤓(.+)", + "🤓", + "😎(.+)", + "😎", + "🤗(.+)", + "🤗", + "😏(.+)", + "😏", + "😶(.+)", + "😶", + "😺(.+)", + "😺", + "😹", + "😼", + "😿", + "🌝", + "🌚", + "🌶", + "🖐🏼", +},run = run} + diff --git a/plugins/lock_join.lua b/plugins/lock_join.lua new file mode 100644 index 00000000..d1253190 --- /dev/null +++ b/plugins/lock_join.lua @@ -0,0 +1,23 @@ +local function run (msg, matches) +local data = load_data(_config.moderation.data) + if matches[1] == 'chat_add_user_link' then + local user_id = msg.from.id + if data[tostring(msg.to.id)] then + if data[tostring(msg.to.id)]['settings'] then + if data[tostring(msg.to.id)]['settings']['lock_join'] == 'yes' then + kick_user(user_id, msg.to.id) + end + end +end + end + end +return { + usage = { + "lock join: Nobody Can't Join Group Via Link.", + "unlock Join: User Can Join Group Via Link.", + }, + patterns = { + "^!!tgservice (chat_add_user_link)$" + }, + run = run +} diff --git a/plugins/lockfwd.lua b/plugins/lockfwd.lua new file mode 100644 index 00000000..20f81ed0 --- /dev/null +++ b/plugins/lockfwd.lua @@ -0,0 +1,50 @@ +do + +local function pre_process(msg) + + local hash = 'mate:'..msg.to.id + if redis:get(hash) and msg.fwd_from and not is_momod(msg) then + chat_del_user('chat#id'..msg.to.id,'user#id'..msg.from.id, ok_cb, false) + return "fwd was locked" + end + + return msg + end + + + + +local function run(msg, matches) + chat_id = msg.to.id + + if matches[1] == 'lock' and is_momod(msg) then + + + local hash = 'mate:'..msg.to.id + redis:set(hash, true) + return "قفل فروارد فعال شد" + elseif matches[1] == 'unlock' and is_momod(msg) then + local hash = 'mate:'..msg.to.id + redis:del(hash) + return "قفل فروارد غیر فعال شد" + end + if matches[1] == 'status' then + local hash = 'mate:'..msg.to.id + if redis:get(hash) then + return "fwd is locked" + else + return "fwd is not locked" + +end +end +end +return { + patterns = { + '^[/!#](lock) fwd$', + '^[/!#](unlock) fwd$', + '^[/!#]fwd (status)$', + }, + run = run, + pre_process = pre_process +} +end \ No newline at end of file diff --git a/plugins/me.lua b/plugins/me.lua new file mode 100644 index 00000000..93d00f34 --- /dev/null +++ b/plugins/me.lua @@ -0,0 +1,74 @@ +do +local function get_msgs_user_chat(user_id, chat_id) + local user_info = {} + local uhash = 'user:'..user_id + local user = redis:hgetall(uhash) + local um_hash = 'msgs:'..user_id..':'..chat_id + user_info.msgs = tonumber(redis:get(um_hash) or 0) + user_info.name = user_print_name(user)..' ['..user_id..']' + return user_info +end +local function chat_stat(chat_id, typee) + -- Users on chat +local hash = '' +if typee == 'channel' then +hash = 'channel:'..chat_id..':users' +else + hash = 'chat:'..chat_id..':users' +end + local users = redis:smembers(hash) + local users_info = {} + + -- Get user info + for i = 1, #users do + local user_id = users[i] + local user_info = get_msgs_user_chat(user_id, chat_id) + table.insert(users_info, user_info) + end + + -- Sort users by msgs number + table.sort(users_info, function(a, b) + if a.msgs and b.msgs then + return a.msgs > b.msgs + end + end) + + local arian = '0' + local text = 'users in this chat \n' + for k,user in pairs(users_info) do + --text = text..user.name..' = '..user.msgs..'\n' + arian = arian + user.msgs + end + return arian +end + local function rsusername_cb(extra, success, result) + if success == 1 then + local user = result.peer_id + local name = string.gsub(result.print_name, "_", " ") + local chatid = get_receiver(extra.msg) + local username = result.username + function round2(num, idp) + return tonumber(string.format("%." .. (idp or 0) .. "f", num)) + end + + local r = tonumber(chat_stat(extra.msg.to.id, extra.msg.to.type) or 0) + + local hashs = 'msgs:'..result.peer_id..':'..extra.msg.to.id + local msgss = redis:get(hashs) + local percent = msgss / r * 100 + return send_large_msg(chatid, "نام شما : "..name.."\nتعداد پیام ها ارسالی توسط شما : "..msgss.." ("..round2(percent).."%)\n تمام پیام های ارسال شده در گروه: "..r.."") + + end +end +local function run(msg, matches) +local chat_id = msg.to.peer_id +--return chat_stat(chat_id) + resolve_username(msg.from.username, rsusername_cb, {msg=msg}) +end + return { + patterns = { + "^اینفو$", + }, + run = run + } +end diff --git a/plugins/rmsg.lua b/plugins/rmsg.lua new file mode 100644 index 00000000..5edcefda --- /dev/null +++ b/plugins/rmsg.lua @@ -0,0 +1,31 @@ +local function history(extra, suc, result) + for i=1, #result do + delete_msg(result[i].id, ok_cb, false) + end + if tonumber(extra.con) == #result then + send_msg(extra.chatid, '"'..#result..'" پیام اخیر سوپر گروه حذف شد', ok_cb, false) + else + send_msg(extra.chatid, 'تعداد پیام مورد نظر شما پاک شد', ok_cb, false) + end +end +local function run(msg, matches) + if matches[1] == 'پاک' and is_owner(msg) then + if msg.to.type == 'channel' then + if tonumber(matches[2]) > 10000 or tonumber(matches[2]) < 1 then + return "تعداد بیشتر از 1 مجاز است" + end + get_history(msg.to.peer_id, matches[2] + 1 , history , {chatid = msg.to.peer_id, con = matches[2]}) + else + return "فقط در سوپرگروه ممکن است" + end + else + return "شما دسترسی ندارید" + end +end + +return { + patterns = { + '^(پاک) (%d*)$' + }, + run = run +} diff --git a/plugins/set.lua b/plugins/set.lua index 9a425fb1..10344b6d 100644 --- a/plugins/set.lua +++ b/plugins/set.lua @@ -8,12 +8,12 @@ local function save_value(msg, name, value) end if hash then redis:hset(hash, name, value) - return "Saved "..name + return "سیو شد "..name end end local function run(msg, matches) if not is_momod(msg) then - return "For moderators only!" + return "فقط مدیران!" end local name = string.sub(matches[1], 1, 50) local value = string.sub(matches[2], 1, 1000) @@ -25,7 +25,7 @@ end return { patterns = { - "^[#!/]save ([^%s]+) (.+)$" + "^سیو ([^%s]+) (.+)$" }, run = run } diff --git a/plugins/setwlc.lua b/plugins/setwlc.lua new file mode 100644 index 00000000..f1470363 --- /dev/null +++ b/plugins/setwlc.lua @@ -0,0 +1,60 @@ +do +local function run(msg, matches, callback, extra) +local data = load_data(_config.moderation.data) +local rules = data[tostring(msg.to.id)]['rules'] +local about = data[tostring(msg.to.id)]['description'] +local hash = 'group:'..msg.to.id +local group_welcome = redis:hget(hash,'welcome') +if matches[1] == 'حذف ولکام' and not matches[2] and is_owner(msg) then + + redis:hdel(hash,'welcome') + return 'متن خوش آمد گویی پاک شد 🗑' +end + +local url , res = http.request('http://api.gpmod.ir/time/') +if res ~= 200 then return "No connection" end +local jdat = json:decode(url) + +if matches[1] == 'تنظیم ولکام' and is_owner(msg) then +redis:hset(hash,'welcome',matches[2]) + return 'متن خوش آمد گویی گروه تنظیم شد به : ✋\n'..matches[2] +end + +if matches[1] == 'chat_add_user' or 'chat_add_user_link' or 'channel_invite' and msg.service then +group_welcome = string.gsub(group_welcome, '{gpname}', msg.to.title) +group_welcome = string.gsub(group_welcome, '{firstname}', ""..(msg.action.user.first_name or '').."") + group_welcome = string.gsub(group_welcome, '{lastname}', ""..(msg.action.user.last_name or '').."") + group_welcome = string.gsub(group_welcome, '{username}', "@"..(msg.action.user.username or '').."") + group_welcome = string.gsub(group_welcome, '{fatime}', ""..(jdat.FAtime).."") + group_welcome = string.gsub(group_welcome, '{entime}', ""..(jdat.ENtime).."") + group_welcome = string.gsub(group_welcome, '{fadate}', ""..(jdat.FAdate).."") + group_welcome = string.gsub(group_welcome, '{endate}', ""..(jdat.ENdate).."") + group_welcome = string.gsub(group_welcome, '{rules}', ""..(rules or '').."") + group_welcome = string.gsub(group_welcome, '{about}', ""..(about or '').."") + + + + +group_welcome = string.gsub(group_welcome, '{نام گروه}', msg.to.title) +group_welcome = string.gsub(group_welcome, '{نام اول}', ""..(msg.action.user.first_name or '').."") + group_welcome = string.gsub(group_welcome, '{نام آخر}', ""..(msg.action.user.last_name or '').."") + group_welcome = string.gsub(group_welcome, '{نام کاربری}', "@"..(msg.action.user.username or '').."") + group_welcome = string.gsub(group_welcome, '{ساعت فارسی}', ""..(jdat.FAtime).."") + group_welcome = string.gsub(group_welcome, '{ساعت انگلیسی}', ""..(jdat.ENtime).."") + group_welcome = string.gsub(group_welcome, '{تاریخ فارسی}', ""..(jdat.FAdate).."") + group_welcome = string.gsub(group_welcome, '{تاریخ انگلیسی}', ""..(jdat.ENdate).."") + + end +return group_welcome +end +return { + patterns = { + "^(تنظیم ولکام) +(.*)$", + "^(حذف ولکام)$", + "^!!tgservice (chat_add_user)$", + "^!!tgservice (invite)$", + "^!!tgservice (chat_add_user_link)$", + }, + run = run +} +end diff --git a/plugins/time2.lua b/plugins/time2.lua new file mode 100644 index 00000000..c142b63b --- /dev/null +++ b/plugins/time2.lua @@ -0,0 +1,13 @@ +local function run(msg, matches) +local url , res = http.request('http://api.gpmod.ir/time/') +if res ~= 200 then return "No connection" end +local jdat = json:decode(url) +local text = '🕒 ساعت '..jdat.FAtime..' \n📆 امروز '..jdat.FAdate..' میباشد.\n ----\n🕒 '..jdat.ENtime..'\n📆 '..jdat.ENdate.. '\n' +return text +end +return { + patterns = { + "^(زمان)$" + }, +run = run +} diff --git a/plugins/times.lua b/plugins/times.lua new file mode 100644 index 00000000..bb247695 --- /dev/null +++ b/plugins/times.lua @@ -0,0 +1,14 @@ +local function run(msg, matches) +local url , res = http.request('http://api.gpmod.ir/time/') +local jdat = json:decode(url) +local url = "http://latex.codecogs.com/png.download?".."\\dpi{800}%20\\LARGE%20"..jdat.ENtime +local file = download_to_file(url,'DeaD.webp') +send_document(get_receiver(msg) , file, ok_cb, false) +end + +return { + patterns = { + "^زمان$" + }, + run = run +}