'
function gps:init(config)
gps.triggers = {
- "^/gps ([^,]*)[,%s]([^,]*)$",
+ "^/[Gg][Pp][Ss] ([^,]*)[,%s]([^,]*)$",
"google.de/maps/@([^,]*)[,%s]([^,]*)",
"google.com/maps/@([^,]*)[,%s]([^,]*)",
"google.de/maps/place/@([^,]*)[,%s]([^,]*)",
diff --git a/miku/plugins/greetings.lua b/miku/plugins/greetings.lua
deleted file mode 100644
index c33693b..0000000
--- a/miku/plugins/greetings.lua
+++ /dev/null
@@ -1,63 +0,0 @@
- -- Put this on the bottom of your plugin list, after help.lua.
- -- If you want to configure your own greetings, copy the following table
- -- (without the "config.") to your config.lua file.
-
-local greetings = {}
-
-local utilities = require('miku.utilities')
-
-function greetings:init(config)
- config.greetings = config.greetings or {
- ['Hello, #NAME.'] = {
- 'hello',
- 'hey',
- 'sup',
- 'hi',
- 'good morning',
- 'good day',
- 'good afternoon',
- 'good evening'
- },
- ['Goodbye, #NAME.'] = {
- 'bye',
- 'later',
- 'see ya',
- 'good night'
- },
- ['Welcome back, #NAME.'] = {
- 'i\'m home',
- 'i\'m back'
- },
- ['You\'re welcome, #NAME.'] = {
- 'thanks',
- 'thank you'
- }
- }
-
- greetings.triggers = {
- self.info.first_name:lower() .. '%p*$'
- }
-end
-
-function greetings:action(msg, config)
-
- local nick = utilities.build_name(msg.from.first_name, msg.from.last_name)
- if self.database.userdata[tostring(msg.from.id)] then
- nick = self.database.userdata[tostring(msg.from.id)].nickname or nick
- end
-
- for trigger,responses in pairs(config.greetings) do
- for _,response in pairs(responses) do
- if msg.text_lower:match(response..',? '..self.info.first_name:lower()) then
- local output = utilities.char.zwnj .. trigger:gsub('#NAME', nick)
- utilities.send_message(self, msg.chat.id, output)
- return
- end
- end
- end
-
- return true
-
-end
-
-return greetings
diff --git a/miku/plugins/hackernews.lua b/miku/plugins/hackernews.lua
deleted file mode 100644
index bb1558e..0000000
--- a/miku/plugins/hackernews.lua
+++ /dev/null
@@ -1,45 +0,0 @@
-local hackernews = {}
-
-local https = require('ssl.https')
-local json = require('dkjson')
-local URL = require('socket.url')
-local utilities = require('miku.utilities')
-
-hackernews.triggers = {
- "news.ycombinator.com/item%?id=(%d+)"
-}
-
-local BASE_URL = 'https://hacker-news.firebaseio.com/v0'
-
-function hackernews:send_hackernews_post (hn_code)
- local url = BASE_URL..'/item/'..hn_code..'.json'
- local res,code = https.request(url)
- if code ~= 200 then return "HTTP-FEHLER" end
- local data = json.decode(res)
-
- local by = data.by
- local title = data.title
-
- if data.url then
- url = '\n[Link besuchen]('..data.url..')'
- else
- url = ''
- end
-
- if data.text then
- post = '\n'..unescape_html(data.text)
- post = string.gsub(post, '', ' ')
- else
- post = ''
- end
- local text = '*'..title..'* von _'..by..'_'..post..url
-
- return text
-end
-
-function hackernews:action(msg, config, matches)
- local hn_code = matches[1]
- utilities.send_reply(self, msg, hackernews:send_hackernews_post(hn_code), true)
-end
-
-return hackernews
diff --git a/miku/plugins/heise.lua b/miku/plugins/heise.lua
deleted file mode 100644
index 1fc085e..0000000
--- a/miku/plugins/heise.lua
+++ /dev/null
@@ -1,48 +0,0 @@
-local heise = {}
-
-local https = require('ssl.https')
-local URL = require('socket.url')
-local json = require('dkjson')
-local utilities = require('miku.utilities')
-local bindings = require('miku.bindings')
-
-heise.triggers = {
- "heise.de/newsticker/meldung/(.*).html$"
- }
-
-function heise:get_heise_article(article)
- local url = 'https://query.yahooapis.com/v1/public/yql?q=select%20content,src,strong%20from%20html%20where%20url=%22http://www.heise.de/newsticker/meldung/'..article..'.html%22%20and%20xpath=%22//div[@id=%27mitte_news%27]/article/header/h2|//div[@id=%27mitte_news%27]/article/div/p[1]/strong|//div[@id=%27mitte_news%27]/article/div/figure/img%22&format=json'
- local res,code = https.request(url)
- local data = json.decode(res).query.results
- if code ~= 200 then return "HTTP-Fehler" end
-
- local title = data.h2
- if data.strong then
- teaser = '\n'..data.strong
- else
- teaser = ''
- end
- if data.img then
- image_url = 'https:'..data.img.src
- end
- local text = '*'..title..'*'..teaser
-
- if data.img then
- return text, image_url
- else
- return text
- end
-end
-
-function heise:action(msg, config, matches)
- local article = URL.escape(matches[1])
- local text, image_url = heise:get_heise_article(article)
- if image_url then
- utilities.send_typing(self, msg.chat.id, 'upload_photo')
- local file = download_to_file(image_url, 'heise_teaser.jpg')
- utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id)
- end
- utilities.send_reply(self, msg, text, true)
-end
-
-return heise
\ No newline at end of file
diff --git a/miku/plugins/hello.lua b/miku/plugins/hello.lua
deleted file mode 100644
index 6ee0cd9..0000000
--- a/miku/plugins/hello.lua
+++ /dev/null
@@ -1,13 +0,0 @@
-local hello = {}
-
-local utilities = require('miku.utilities')
-
-hello.triggers = {
- "^[Ss][Aa][Gg] [Hh][Aa][Ll][Ll][Oo] [Zz][Uu] (.*)$"
-}
-
-function hello:action(msg, config, matches)
- utilities.send_reply(self, msg, 'Hallo, '..matches[1]..'!')
-end
-
-return hello
diff --git a/miku/plugins/id.lua b/miku/plugins/id.lua
index 9f435a7..0cbc974 100644
--- a/miku/plugins/id.lua
+++ b/miku/plugins/id.lua
@@ -11,10 +11,7 @@ function id:init(config)
"^/id$",
"^/ids? (chat)$"
}
- id.doc = [[```
-Returns user and chat info for you or the replied-to message.
-Alias: ]]..config.cmd_pat..[[who
-```]]
+ id.doc = [[```Zeige dir deine ID und die IDs aller Gruppenmitglieder an.``]]
end
function id:get_member_count(self, msg, chat_id)
diff --git a/miku/plugins/ifttt.lua b/miku/plugins/ifttt.lua
deleted file mode 100644
index b4dba17..0000000
--- a/miku/plugins/ifttt.lua
+++ /dev/null
@@ -1,80 +0,0 @@
-local ifttt = {}
-
-local https = require('ssl.https')
-local URL = require('socket.url')
-local redis = (loadfile "./miku/redis.lua")()
-local utilities = require('miku.utilities')
-local bindings = require('miku.bindings')
-
-function ifttt:init(config)
- ifttt.triggers = {
- "^/ifttt (!set) (.*)$",
- "^/ifttt (!unauth)$",
- "^/ifttt (.*)%&(.*)%&(.*)%&(.*)",
- "^/ifttt (.*)%&(.*)%&(.*)",
- "^/ifttt (.*)%&(.*)",
- "^/ifttt (.*)$"
- }
-
- ifttt.doc = [[*
-]]..config.cmd_pat..[[ifttt* _!set_ __: Speichere deinen Schlüssel ein (erforderlich)
-*]]..config.cmd_pat..[[ifttt* _!unauth_: Löscht deinen Account aus dem Bot
-*]]..config.cmd_pat..[[ifttt* __&__&__&__: Führt [Event] mit den optionalen Parametern Value1, Value2 und Value3 aus
-Beispiel: `/ifttt DeinFestgelegterName&Hallo&NochEinHallo`: Führt 'DeinFestgelegterName' mit den Parametern 'Hallo' und 'NochEinHallo' aus.]]
-end
-
-ifttt.command = 'ifttt &&&'
-
-local BASE_URL = 'https://maker.ifttt.com/trigger'
-
-function ifttt:set_ifttt_key(hash, key)
- print('Setting ifttt in redis hash '..hash..' to '..key)
- redis:hset(hash, 'ifttt', key)
- return '*Schlüssel eingespeichert!* Das Plugin kann jetzt verwendet werden.'
-end
-
-function ifttt:do_ifttt_request(key, event, value1, value2, value3)
- if not value1 then
- url = BASE_URL..'/'..event..'/with/key/'..key
- elseif not value2 then
- url = BASE_URL..'/'..event..'/with/key/'..key..'/?value1='..URL.escape(value1)
- elseif not value3 then
- url = BASE_URL..'/'..event..'/with/key/'..key..'/?value1='..URL.escape(value1)..'&value2='..URL.escape(value2)
- else
- url = BASE_URL..'/'..event..'/with/key/'..key..'/?value1='..URL.escape(value1)..'&value2='..URL.escape(value2)..'&value3='..URL.escape(value3)
- end
-
- local res,code = https.request(url)
- if code ~= 200 then return "*Ein Fehler ist aufgetreten!* Aktion wurde nicht ausgeführt." end
-
- return "*Event \""..event.."\" getriggert!*"
-end
-
-function ifttt:action(msg, config, matches)
- local hash = 'user:'..msg.from.id
- local key = redis:hget(hash, 'ifttt')
- local event = matches[1]
- local value1 = matches[2]
- local value2 = matches[3]
- local value3 = matches[4]
-
- if event == '!set' then
- utilities.send_reply(self, msg, ifttt:set_ifttt_key(hash, value1), true)
- return
- end
-
- if not key then
- utilities.send_reply(self, msg, '*Bitte speichere zuerst deinen Schlüssel ein!* Aktiviere dazu den [Maker Channel](https://ifttt.com/maker) und speichere deinen Schlüssel mit `/ifttt !set KEY` ein', true)
- return
- end
-
- if event == '!unauth' then
- redis:hdel(hash, 'ifttt')
- utilities.send_reply(self, msg, '*Erfolgreich ausgeloggt!*', true)
- return
- end
-
- utilities.send_reply(self, msg, ifttt:do_ifttt_request(key, event, value1, value2, value3), true)
-end
-
-return ifttt
\ No newline at end of file
diff --git a/miku/plugins/instagram.lua b/miku/plugins/instagram.lua
deleted file mode 100644
index d411cbf..0000000
--- a/miku/plugins/instagram.lua
+++ /dev/null
@@ -1,80 +0,0 @@
-local instagram = {}
-
-local https = require('ssl.https')
-local json = require('dkjson')
-local URL = require('socket.url')
-local utilities = require('miku.utilities')
-
-function instagram:init(config)
- if not cred_data.instagram_access_token then
- print('Missing config value: instagram_access_token.')
- print('instagram.lua will not be enabled.')
- return
- end
-
- instagram.triggers = {
- "instagram.com/p/([A-Za-z0-9-_-]+)"
- }
-end
-
-local BASE_URL = 'https://api.instagram.com/v1'
-local access_token = cred_data.instagram_access_token
-
-function instagram:get_insta_data(insta_code)
- local url = BASE_URL..'/media/shortcode/'..insta_code..'?access_token='..access_token
- local res,code = https.request(url)
- if code ~= 200 then return nil end
- local data = json.decode(res).data
- return data
-end
-
-function instagram:send_instagram_data(data)
- -- Header
- local username = data.user.username
- local full_name = data.user.full_name
- if username == full_name then
- header = full_name..' hat ein'
- else
- header = full_name..' ('..username..') hat ein'
- end
- if data.type == 'video' then
- header = header..' Video gepostet'
- else
- header = header..' Foto gepostet'
- end
-
- -- Caption
- if data.caption == nil then
- caption = ''
- else
- caption = ':\n'..data.caption.text
- end
-
- -- Footer
- local comments = comma_value(data.comments.count)
- local likes = comma_value(data.likes.count)
- local footer = '\n'..likes..' Likes, '..comments..' Kommentare'
- if data.type == 'video' then
- footer = '\n'..data.videos.standard_resolution.url..footer
- end
-
- -- Image
- local image_url = data.images.standard_resolution.url
-
- return header..caption..footer, image_url
-end
-
-function instagram:action(msg, config, matches)
- local insta_code = matches[1]
- local data = instagram:get_insta_data(insta_code)
- if not data then utilities.send_reply(self, msg, config.errors.connection) return end
-
- local text, image_url = instagram:send_instagram_data(data)
- if not image_url then utilities.send_reply(self, msg, config.errors.connection) return end
-
- utilities.send_typing(self, msg.chat.id, 'upload_photo')
- local file = download_to_file(image_url)
- utilities.send_photo(self, msg.chat.id, file, text, msg.message_id)
-end
-
-return instagram
diff --git a/miku/plugins/isup.lua b/miku/plugins/isup.lua
index 1c5a4ac..cbdafa6 100644
--- a/miku/plugins/isup.lua
+++ b/miku/plugins/isup.lua
@@ -8,8 +8,8 @@ local utilities = require('miku.utilities')
function isup:init(config)
isup.triggers = {
- "^/isup (.*)$",
- "^/ping (.*)$"
+ "^/[Ii][Ss][Uu][Pp] (.*)$",
+ "^/[Pp][Ii][Nn][Gg] (.*)$"
}
isup.doc = [[*
diff --git a/miku/plugins/location_manager.lua b/miku/plugins/location_manager.lua
index 9d8a194..46c3870 100644
--- a/miku/plugins/location_manager.lua
+++ b/miku/plugins/location_manager.lua
@@ -5,9 +5,9 @@ local redis = (loadfile "./miku/redis.lua")()
function loc_manager:init(config)
loc_manager.triggers = {
- "^/location (set) (.*)$",
- "^/location (del)$",
- "^/location$"
+ "^/[Ll][Oo][Cc][Aa][Tt][Ii][Oo][Nn] (set) (.*)$",
+ "^/[Ll][Oo][Cc][Aa][Tt][Ii][Oo][Nn] (del)$",
+ "^/[Ll][Oo][Cc][Aa][Tt][Ii][Oo][Nn]$"
}
loc_manager.doc = [[*
]]..config.cmd_pat..[[location*: Gibt deinen gesetzten Wohnort aus
diff --git a/miku/plugins/luarun.lua b/miku/plugins/luarun.lua
deleted file mode 100644
index b8d9176..0000000
--- a/miku/plugins/luarun.lua
+++ /dev/null
@@ -1,53 +0,0 @@
-local luarun = {}
-
-local utilities = require('miku.utilities')
-local URL = require('socket.url')
-local JSON = require('dkjson')
-
-function luarun:init(config)
- luarun.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('lua', true):t('return', true).table
-end
-
-function luarun:action(msg, config)
-
- if msg.from.id ~= config.admin then
- return true
- end
-
- local input = utilities.input(msg.text)
- if not input then
- utilities.send_reply(self, msg, 'Please enter a string to load.')
- return
- end
-
- if msg.text_lower:match('^'..config.cmd_pat..'return') then
- input = 'return ' .. input
- end
-
- local output = loadstring( [[
- local bot = require('miku.bot')
- local bindings = require('miku.bindings')
- local utilities = require('miku.utilities')
- local JSON = require('dkjson')
- local URL = require('socket.url')
- local HTTP = require('socket.http')
- local HTTPS = require('ssl.https')
- return function (self, msg, config) ]] .. input .. [[ end
- ]] )()(self, msg, config)
- if output == nil then
- output = 'Done!'
- else
- if type(output) == 'table' then
- local s = JSON.encode(output, {indent=true})
- if URL.escape(s):len() < 4000 then
- output = s
- end
- end
- output = '```\n' .. tostring(output) .. '\n```'
- end
- utilities.send_message(self, msg.chat.id, output, true, msg.message_id, true)
-
-end
-
-return luarun
-
diff --git a/miku/plugins/magische_miesmuschel.lua b/miku/plugins/magische_miesmuschel.lua
index 6aeabc8..d8adbd3 100644
--- a/miku/plugins/magische_miesmuschel.lua
+++ b/miku/plugins/magische_miesmuschel.lua
@@ -3,7 +3,7 @@ local muschel = {}
local utilities = require('miku.utilities')
muschel.triggers = {
- "^[Mm][Aa][Gg][Ii][Ss][Cc][Hh][Ee] [Mm][Ii][Ee][Ss][Mm][Uu][Ss][Cc][Hh][Ee][Ll], (.*)$"
+ "^[Mm][Aa][Gg][Ii][Ss][Cc][Hh][Ee] [Mm][Ii][Ee][Ss][Mm][Uu][Ss][Cc][Hh][Ee][Ll] (.*)$"
}
function muschel:frag_die_muschel()
diff --git a/miku/plugins/media.lua b/miku/plugins/media.lua
index 7bd97b1..edc4131 100644
--- a/miku/plugins/media.lua
+++ b/miku/plugins/media.lua
@@ -21,6 +21,7 @@ media.triggers = {
"^(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(avi))$",
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(wav))$",
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(apk))$",
+ "(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(ipa))$",
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(webm))$",
"^(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(ogv))$",
"(https?://[%w-_%.%?%.:,/%+=&%[%]]+%.(webp))$"
diff --git a/miku/plugins/myanimelist.lua b/miku/plugins/myanimelist.lua
index 1571f0c..7268318 100644
--- a/miku/plugins/myanimelist.lua
+++ b/miku/plugins/myanimelist.lua
@@ -9,8 +9,8 @@ local bindings = require('miku.bindings')
mal.command = 'anime , /manga '
function mal:init(config)
- if not cred_data.mal_user then
- print('Missing config value: mal_user.')
+ if not cred_data.mal_username then
+ print('Missing config value: mal_username.')
print('myanimelist.lua will not be enabled.')
return
elseif not cred_data.mal_pw then
@@ -21,6 +21,7 @@ function mal:init(config)
mal.triggers = {
"^/(anime) (.+)$",
+ "^/(mal) (.+)$",
"^/(manga) (.+)$"
}
mal.doc = [[*
@@ -29,7 +30,7 @@ function mal:init(config)
]]
end
-local user = cred_data.mal_user
+local user = cred_data.mal_username
local password = cred_data.mal_pw
local BASE_URL = 'http://'..user..':'..password..'@myanimelist.net/api'
@@ -192,7 +193,7 @@ end
function mal:action(msg, config, matches)
local query = URL.escape(matches[2])
- if matches[1] == 'anime' then
+ if matches[1] == 'anime' or matches[1] == 'mal' then
local anime_info = mal:get_mal_info(query, 'anime')
if anime_info == "HTTP-Fehler" then
utilities.send_reply(self, msg, 'Anime nicht gefunden!')
diff --git a/miku/plugins/rss.lua b/miku/plugins/rss.lua
index aeb0e30..93cdd58 100644
--- a/miku/plugins/rss.lua
+++ b/miku/plugins/rss.lua
@@ -78,6 +78,18 @@ function unescape_for_rss(str)
return str
end
+function cleanRSS(cleantext)
+ cleantext = string.gsub(cleantext, '%[mehr%]', '')
+ cleantext = string.gsub(cleantext, '%[video%]', '')
+ cleantext = string.gsub(cleantext, '...%[more%]', '')
+ cleantext = string.gsub(cleantext, '%[more%]', '')
+ cleantext = string.gsub(cleantext, 'Click for full.', '')
+ cleantext = string.gsub(cleantext, 'Read more »', '')
+ cleantext = string.gsub(cleantext, 'Meldung bei www.tagesschau.de lesen', '')
+
+ return cleantext
+end
+
function get_base_redis(id, option, extra)
local ex = ''
if option ~= nil then
@@ -344,7 +356,8 @@ function rss:cron(self_plz)
else
content = ''
end
- text = text..'\n*[*#RSS*] '..title..'*\n'..utilities.trim(utilities.markdown_escape_simple(content))..' [Weiterlesen]('..link..')\n'
+ content = cleanRSS(content)
+ text = text..'\n*[*#RSS*] '..title..'*\n'..utilities.trim(utilities.md_escape(content))..' [Weiterlesen]('..link..')\n'
end
if text ~= '' then
local newlast = newentr[1].id
diff --git a/miku/plugins/youtube.lua b/miku/plugins/youtube.lua
index cbb1c38..466e205 100644
--- a/miku/plugins/youtube.lua
+++ b/miku/plugins/youtube.lua
@@ -34,6 +34,13 @@ local makeOurDate = function(dateString)
return day..'.'..month..'.'..year
end
+function markdown_escape_simple(text)
+ text = text:gsub('_', '\\_')
+ text = text:gsub('%*', '\\*')
+ text = text:gsub('`', '\\`')
+ return text
+end
+
function get_yt_data (yt_code)
local apikey = cred_data.google_apikey
local url = BASE_URL..'/videos?part=snippet,statistics,contentDetails&key='..apikey..'&id='..yt_code..'&fields=items(snippet(publishedAt,channelTitle,localized(title,description),thumbnails),statistics(viewCount,likeCount,dislikeCount,commentCount),contentDetails(duration,regionRestriction(blocked)))'
@@ -98,7 +105,7 @@ function get_yt_thumbnail(data)
end
function send_youtube_data(data, msg, self, link, sendpic)
- local title = utilities.markdown_escape_simple(data.snippet.localized.title)
+ local title = markdown_escape_simple(data.snippet.localized.title)
-- local description = data.snippet.localized.description
local uploader = data.snippet.channelTitle
local upload_date = makeOurDate(data.snippet.publishedAt)
diff --git a/miku/utilities.lua b/miku/utilities.lua
index bf04b8f..e6871fb 100644
--- a/miku/utilities.lua
+++ b/miku/utilities.lua
@@ -491,14 +491,6 @@ end
function utilities.markdown_escape(text)
text = text:gsub('_', '\\_')
text = text:gsub('%[', '\\[')
- text = text:gsub('%]', '\\]')
- text = text:gsub('%*', '\\*')
- text = text:gsub('`', '\\`')
- return text
-end
-
-function utilities.markdown_escape_simple(text)
- text = text:gsub('_', '\\_')
text = text:gsub('%*', '\\*')
text = text:gsub('`', '\\`')
return text