diff --git a/miku/plugins/akasblog.lua b/miku/plugins/wordpress_posts.lua
similarity index 67%
rename from miku/plugins/akasblog.lua
rename to miku/plugins/wordpress_posts.lua
index 3eaedea..2f6e9c5 100644
--- a/miku/plugins/akasblog.lua
+++ b/miku/plugins/wordpress_posts.lua
@@ -1,8 +1,9 @@
local wordpress_recent_post = {}
-function wordpress_recent_post:init(config)
- wordpress_recent_post.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('aka', true).table
-end
+wordpress_recent_post.triggers = {
+ "^/([Aa][Kk][Aa])$",
+ "^/([Pp][Ww])$"
+}
local makeOurDate = function(dateString)
local pattern = "(%d+)%-(%d+)%-(%d+)"
@@ -10,9 +11,13 @@ local makeOurDate = function(dateString)
return day..'.'..month..'.'..year
end
-function wordpress_recent_post:get_full_url()
- local url = 'http://akamaru.de/?json=get_recent_posts'
- local res,code = http.request(url)
+function wordpress_recent_post:get_full_url(blog)
+ local url = blog..'/?json=get_recent_posts'
+ local doer = http
+ if url:match('^https') then
+ doer = https
+ end
+ local res, code = doer.request(url)
if code ~= 200 then return nil end
local data = json.decode(res).posts[1]
if not data then return nil end
@@ -35,15 +40,20 @@ function wordpress_recent_post:get_full_url()
local text = ''..title..'\n'..from..' am '..posted_at..'\n'..content..'...\nArtikel aufrufen'
if image_url then
- local text = title..' ('..from..' am '..posted_at..')\n\n'..content..'...\n'..url -- captions don't supported markdowns
+ local text = title..' ('..from..' am '..posted_at..')\n\n'..content..'...\n'..url -- captions don't support markdown
return text, image_url
else
return text
end
end
-function wordpress_recent_post:action(msg, config)
- local text, image_url = wordpress_recent_post:get_full_url()
+function wordpress_recent_post:action(msg, config, matches)
+ if matches[1]:match('[Aa][Kk][Aa]') then
+ blog = 'http://akamaru.de'
+ elseif matches[1]:match('[Pp][Ww]') then
+ blog = 'https://ponywave.de'
+ end
+ local text, image_url = wordpress_recent_post:get_full_url(blog)
if not text then
utilities.send_reply(self, msg, config.errors.connection)
return