Skip to content
416 changes: 194 additions & 222 deletions bot/seedbot.lua

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions plugins/aparat.lua
Original file line number Diff line number Diff line change
@@ -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
}
56 changes: 56 additions & 0 deletions plugins/aparatdl.lua
Original file line number Diff line number Diff line change
@@ -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 =
'<meta%sproperty="og%:video%:url"%scontent="([:/_A-Za-z0-9-.]+.mp4)">'
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
100 changes: 100 additions & 0 deletions plugins/azan.lua
Original file line number Diff line number Diff line change
@@ -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 ..
"&center=" .. 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
Loading