40
plugins/pluginsold/facebook.lua
Normal file
40
plugins/pluginsold/facebook.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
-- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 <andi (dot) b (at) outlook (dot) de>
|
||||
-- DO NOT USE WITHOUT PERMISSION
|
||||
|
||||
do
|
||||
|
||||
local BASE_URL = 'https://graph.facebook.com'
|
||||
|
||||
function get_fb_data (fb_code)
|
||||
local access_token = cred_data.fb_access_token
|
||||
local url = BASE_URL..'/'..fb_code..'?access_token='..access_token..'&locale=de_DE'
|
||||
local res,code = https.request(url)
|
||||
if code ~= 200 then return "HTTP-FEHLER" end
|
||||
local data = json:decode(res)
|
||||
return data
|
||||
end
|
||||
|
||||
function send_fb_data(data, receiver)
|
||||
local from = data.from.name
|
||||
local message = data.message
|
||||
local name = data.name
|
||||
local link = data.link
|
||||
local text = from..' hat gepostet:\n'..message..'\n'..name..' '..link
|
||||
send_msg(receiver, text, ok_cb, false)
|
||||
end
|
||||
|
||||
function run(msg, matches)
|
||||
local fb_code = matches[2]
|
||||
local data = get_fb_data(fb_code)
|
||||
local receiver = get_receiver(msg)
|
||||
send_fb_data(data, receiver)
|
||||
end
|
||||
|
||||
return {
|
||||
description = "Sendet Facebook-Post.",
|
||||
usage = {"Link zu einem Facebook-Post"},
|
||||
patterns = {"facebook.com/([A-Za-z0-9-_-]+)/posts/([0-9-]+)","facebook.com/permalink.([a-z-]+)%?story_fbid=([0-9-]+)"},
|
||||
run = run
|
||||
}
|
||||
|
||||
end
|
||||
46
plugins/pluginsold/facebook_photo.lua
Normal file
46
plugins/pluginsold/facebook_photo.lua
Normal file
@@ -0,0 +1,46 @@
|
||||
-- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 <andi (dot) b (at) outlook (dot) de>
|
||||
-- DO NOT USE WITHOUT PERMISSION
|
||||
|
||||
do
|
||||
|
||||
local BASE_URL = 'https://graph.facebook.com'
|
||||
|
||||
function get_fbphoto_data (fbphoto_code)
|
||||
local access_token = cred_data.fb_access_token
|
||||
local url = BASE_URL..'/'..fbphoto_code..'?access_token='..access_token..'&locale=de_DE'
|
||||
local res,code = https.request(url)
|
||||
if code ~= 200 then return "HTTP-FEHLER" end
|
||||
local data = json:decode(res)
|
||||
return data
|
||||
end
|
||||
|
||||
function send_fbphoto_data(data, receiver)
|
||||
local from = data.from.name
|
||||
local name = data.name
|
||||
if name then
|
||||
text = from..' hat ein Bild gepostet:\n'..name
|
||||
else
|
||||
text = from..' hat ein Bild gepostet'
|
||||
end
|
||||
local image_url = data.source
|
||||
local cb_extra = {
|
||||
receiver=receiver,
|
||||
url=image_url
|
||||
}
|
||||
send_msg(receiver, text, send_photo_from_url_callback, cb_extra)
|
||||
end
|
||||
|
||||
function run(msg, matches)
|
||||
local fbphoto_code = matches[3]
|
||||
local data = get_fbphoto_data(fbphoto_code)
|
||||
local receiver = get_receiver(msg)
|
||||
send_fbphoto_data(data, receiver)
|
||||
end
|
||||
|
||||
return {
|
||||
description = "Sendet Facebook-Bilder-Post",
|
||||
usage = "URL zu öffentlichem Facebook-Bild",
|
||||
patterns = {"facebook.com/([A-Za-z0-9-._-]+)/photos/([A-Za-z0-9-._-]+)/([A-Za-z0-9-._-]+)"},
|
||||
run = run
|
||||
}
|
||||
end
|
||||
39
plugins/pluginsold/facebook_video.lua
Normal file
39
plugins/pluginsold/facebook_video.lua
Normal file
@@ -0,0 +1,39 @@
|
||||
-- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 <andi (dot) b (at) outlook (dot) de>
|
||||
-- DO NOT USE WITHOUT PERMISSION
|
||||
|
||||
do
|
||||
|
||||
local BASE_URL = 'https://graph.facebook.com'
|
||||
|
||||
function get_fbvid_data (fbvid_code)
|
||||
local access_token = cred_data.fb_access_token
|
||||
local url = BASE_URL..'/'..fbvid_code..'?access_token='..access_token..'&locale=de_DE'
|
||||
local res,code = https.request(url)
|
||||
if code ~= 200 then return "HTTP-FEHLER" end
|
||||
local data = json:decode(res)
|
||||
return data
|
||||
end
|
||||
|
||||
function send_fbvid_data(data, receiver)
|
||||
local from = data.from.name
|
||||
local description = data.description
|
||||
local source = data.source
|
||||
local text = from..' hat ein Video gepostet:\n'..description..'\n'..source
|
||||
send_msg(receiver, text, ok_cb, false)
|
||||
end
|
||||
|
||||
function run(msg, matches)
|
||||
local fbvid_code = matches[1]
|
||||
local data = get_fbvid_data(fbvid_code)
|
||||
local receiver = get_receiver(msg)
|
||||
send_fbvid_data(data, receiver)
|
||||
end
|
||||
|
||||
return {
|
||||
description = "Sendet Facebook-Video.",
|
||||
usage = {"Link zu einem Video auf Facebook"},
|
||||
patterns = {"facebook.com/video.php%?v=([0-9-]+)"},
|
||||
run = run
|
||||
}
|
||||
|
||||
end
|
||||
84
plugins/pluginsold/rss_old.lua
Normal file
84
plugins/pluginsold/rss_old.lua
Normal file
@@ -0,0 +1,84 @@
|
||||
-- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 <andi (dot) b (at) outlook (dot) de>
|
||||
-- DO NOT USE WITHOUT PERMISSION
|
||||
|
||||
-- DIES IST EINE PREVIEW!
|
||||
|
||||
-- Ok Leute, ich zeig euch mal, wie der Hase l<>uft:
|
||||
-- 1. Erstelle die Datei data/feeds.lua
|
||||
-- 2. Paste das rein: https://wiidatabase.de/paste/?0772d759b7b49773#7ubf6C8IP78JoafaPK/XrnhhL03cvDgIUCQULTQNYIs=
|
||||
-- 3. Du kannst mehr Feeds hinzuf<75>gen - mehr Feeds gehen mehr auf die Perfomance und k<>nnen schnell nerven, also vorsicht! Ich empfehle 2-3
|
||||
-- (die Feeds und Feednamen kannst du nat<61>rlich beliebig ver<65>ndern, vergiss nicht, dass das Komma hinter dem letzten Feed weg muss!)
|
||||
-- 4. Erstelle die Datei data/feeddata.lua
|
||||
-- 5. Paste das rein: https://wiidatabase.de/paste/?87e36c6a5e2ae337#SGE2KLMJL1+oJ8gmLhHav4WxMqU1gYvIyWZxXJQHg7k=
|
||||
-- 6. Ersetze die Variablen ("wiidatabase", "heise") durch deine Variablen aus der feeds.lua. Zwischen den '' sollte nichts stehen
|
||||
-- 7. <20>ndere hier deine IP und die chat#id
|
||||
-- 8. Starte den Bot, er holt sich die Feeds und schreibt deine feeddata.lua neu
|
||||
|
||||
do
|
||||
|
||||
local socket = require('socket')
|
||||
local _file_feeddata = './data/feeddata.lua'
|
||||
|
||||
function get_feed_data(feed_url)
|
||||
-- You don't need any IP, but Google won't block you, if you provide one!
|
||||
local userip = '84.144.215.197' -- plz change to your IP or leave blank
|
||||
local url = 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q='..feed_url..'&hl=de&num=1&userip='..userip
|
||||
|
||||
local res,code = https.request(url)
|
||||
if code ~= 200 then return "HTTP-FEHLER" end
|
||||
local data = json:decode(res).responseData.feed
|
||||
return data
|
||||
end
|
||||
|
||||
function unescape(str)
|
||||
str = string.gsub( str, '<', '<' )
|
||||
str = string.gsub( str, '>', '>' )
|
||||
str = string.gsub( str, '"', '"' )
|
||||
str = string.gsub( str, ''', "'" )
|
||||
str = string.gsub( str, '&#(%d+);', function(n) return string.char(n) end )
|
||||
str = string.gsub( str, '&#x(%d+);', function(n) return string.char(tonumber(n,16)) end )
|
||||
str = string.gsub( str, '&', '&' ) -- Be sure to do this after all others
|
||||
return str
|
||||
end
|
||||
|
||||
function check_feed(msg, matches)
|
||||
local dest = "chat#id9587278" -- Plz change this, you can find your group id with "chat_info GROUP_NAME"
|
||||
local _file_rss = loadfile ("./data/feeddata.lua")()
|
||||
local _file_feeds = loadfile ("./data/feeds.lua")()
|
||||
feeddata = io.open(_file_feeddata, "w")
|
||||
feeddata:write("do local _ = {\n")
|
||||
|
||||
-- loop through feeds.lua
|
||||
for int_feedname, feed_url in pairs(_file_feeds) do
|
||||
local data = get_feed_data(feed_url)
|
||||
print(data.title)
|
||||
print('Erhalten: '..data.entries[1].link)
|
||||
print('Gespeichert: '.._file_rss[int_feedname]..'\n')
|
||||
if data.entries[1].link ~= _file_rss[int_feedname] then
|
||||
local link = data.entries[1].link
|
||||
local feed_title = data.title
|
||||
local title = data.entries[1].title
|
||||
local content = string.sub(unescape(data.entries[1].content:gsub("%b<>", "")), 1, 250) .. '...'
|
||||
local text = title..'\n'..content..'\n\n -- '..link..' ('..feed_title..')'
|
||||
|
||||
send_msg(dest, text, ok_cb, false)
|
||||
feeddata:write(" "..int_feedname.." = '"..link.."',\n")
|
||||
else
|
||||
-- //TODO: find a better way to rewrite lua when the feed is not updated
|
||||
feeddata:write(" "..int_feedname.." = '"..data.entries[1].link.."',\n") -- ew, I hate this workaround
|
||||
end
|
||||
end
|
||||
feeddata:write(" Ende = Ende\n") -- Dirty hack, remember me to not show this to anybody
|
||||
feeddata:write("}\nreturn _\nend")
|
||||
feeddata:close()
|
||||
end
|
||||
|
||||
return {
|
||||
description = "Sendet RSS-Feeds (public preview)",
|
||||
usage = "",
|
||||
patterns = {},
|
||||
run = run,
|
||||
cron = check_feed
|
||||
}
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user