From c7d6d5acd488ef860cabacfaa0c4da018942f792 Mon Sep 17 00:00:00 2001 From: mohamadkhoshnava Date: Tue, 19 Apr 2016 11:21:24 +0430 Subject: [PATCH] Update bot.lua --- bot.lua | 69 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 11 deletions(-) diff --git a/bot.lua b/bot.lua index b91b393..034ba47 100644 --- a/bot.lua +++ b/bot.lua @@ -6,8 +6,8 @@ JSON = require('dkjson') HTTPS = require('ssl.https') dofile('utilities.lua') ----config---- -local bot_api_key = "145907392:AAFjCN-_5ChWZuGvp6R2VbdbKZ3g6nK4X8U" --التوكم هنا -local You = 188548712 --خلي ايدي حسابك +local bot_api_key = "145907392:AAFjCN-_5ChWZuGvp6R2VbdbKZ3g6nK4X8U" +local You = 188548712 local BASE_URL = "https://api.telegram.org/bot"..bot_api_key local BASE_FOLDER = "" local start = [[ ]] @@ -19,22 +19,22 @@ local help = [[ ➖➖➖➖➖➖➖➖➖➖➖ *commands:*`for admin` `/ban` ✴️ - +بن کردن یک شخص `/unban` ✴️ - +ان بن کردن یک شخص `/users` ✴️ - +تعداد کاربران `/broadcast` ✴️ - +شروع پیام همگانی `/unbroadcast` ✴️ - +پایان ارسال پیام همگانی `/start` ✴️ - +شروع `/id` ✴️ - +ایدی ➖➖➖➖➖➖➖➖➖➖➖ M.KH @cruel0098 -]]--اوامر المساعدة +]]--ة ------- ----utilites---- @@ -248,7 +248,7 @@ function download_to_file(url, file_name, file_path) file:close() return file_path end --------- @MALVOO & @DEV_MICO +-------- @cruel0098 M.KH function bot_run() bot = nil @@ -287,6 +287,53 @@ function bot_run() end function msg_processor(msg) + +if msg.text:match('/p (.*)')then +local matches = {string.match(msg.text,('/p (.*)'))} +local input = get_word(matches[1]) +local lid = resolve_username(input) +local phl = getUserProfilePhotos(tonumber(lid)) +local file = phl.result.photos[1][1].file_id +print(file) +local url = BASE_URL .. '/getFile?file_id='..file + local res = HTTPS.request(url) + local jres = JSON.decode(res) +local caption = "his id :- "..lid + +sendPhotoID(msg.chat.id,file,caption) +elseif msg.reply_to_message and msg.text == '/p' then +local lid = msg.reply_to_message.from.id +local phl = getUserProfilePhotos(tonumber(lid)) +local file = phl.result.photos[1][1].file_id +print(file) +local url = BASE_URL .. '/getFile?file_id='..file + local res = HTTPS.request(url) + local jres = JSON.decode(res) +local caption = "his id :- "..lid + +sendPhotoID(msg.chat.id,file,caption) + +elseif msg.text == '/p' then +local ph = getUserProfilePhotos(msg.from.id) +local file = ph.result.photos[1][1].file_id +local url = BASE_URL .. '/getFile?file_id='..file + local res = HTTPS.request(url) + local jres = JSON.decode(res) + +if msg.from.username ~= nil then +msg.from.username = '@'..msg.from.username +elseif msg.from.username == nil then +msg.from.username = "you don't have" +end +local caption = 'your nam :- '..msg.from.first_name..'\nyour id :-'..msg.from.id..'\nyour username :- '..msg.from.username + + sendPhotoID(msg.chat.id,file,caption) +elseif msg.text:match('/id (.*)$') then +local matches = {string.match(msg.text,('/id (.*)'))} + local input = get_word(matches[1]) + id = resolve_username(input) +sendMessage(msg.chat.id,id) + if msg.text == "/start" and not is_add(msg) then table.insert(add.id,msg.from.id) print("adding.....")