Packe "function unescape" in encoding.lua
Character encoding extreme!
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
local app_store = {}
|
||||
|
||||
require "./miku/encoding"
|
||||
|
||||
app_store.triggers = {
|
||||
"itunes.apple.com/(.*)/app/(.*)/id(%d+)",
|
||||
"^/[Ii][Tt][Uu][Nn][Ee][Ss] (%d+)$",
|
||||
@@ -34,7 +36,7 @@ function app_store:send_appstore_data(data)
|
||||
local version = data.version
|
||||
|
||||
-- Body
|
||||
local description = string.sub(unescape(data.description), 1, 150) .. '...'
|
||||
local description = string.sub(encoding(data.description), 1, 150) .. '...'
|
||||
local min_ios_ver = data.minimumOsVersion
|
||||
local size = string.gsub(round(data.fileSizeBytes / 1000000, 2), "%.", ",") -- wtf Apple, it's 1024, not 1000!
|
||||
local release = makeOurDate(data.releaseDate)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local mal = {}
|
||||
|
||||
local xml = require("xml")
|
||||
require "./miku/encoding"
|
||||
|
||||
mal.command = 'anime <Anime>, /manga <Manga>'
|
||||
|
||||
@@ -117,7 +118,7 @@ function mal:send_anime_data(result, receiver)
|
||||
end
|
||||
|
||||
if xml.find(result, 'synopsis')[1] then
|
||||
desc = '\n_'..unescape(mal:delete_tags(string.sub(xml.find(result, 'synopsis')[1], 1, 250)))..'..._'
|
||||
desc = '\n_'..encoding(mal:delete_tags(string.sub(xml.find(result, 'synopsis')[1], 1, 250)))..'..._'
|
||||
else
|
||||
desc = ''
|
||||
end
|
||||
@@ -144,7 +145,7 @@ function mal:send_manga_data(result)
|
||||
end
|
||||
|
||||
if xml.find(result, 'synonyms')[1] then
|
||||
alt_name = '\noder: '..unescape(mal:delete_tags(xml.find(result, 'synonyms')[1]))
|
||||
alt_name = '\noder: '..encoding(mal:delete_tags(xml.find(result, 'synonyms')[1]))
|
||||
else
|
||||
alt_name = ''
|
||||
end
|
||||
@@ -186,7 +187,7 @@ function mal:send_manga_data(result)
|
||||
end
|
||||
|
||||
if xml.find(result, 'synopsis')[1] then
|
||||
desc = '\n'..unescape(mal:delete_tags(string.sub(xml.find(result, 'synopsis')[1], 1, 200))) .. '...'
|
||||
desc = '\n'..encoding(mal:delete_tags(string.sub(xml.find(result, 'synopsis')[1], 1, 200))) .. '...'
|
||||
else
|
||||
desc = ''
|
||||
end
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
local reddit = {}
|
||||
|
||||
require "./miku/encoding"
|
||||
|
||||
reddit.command = 'reddit [r/subreddit | Suchbegriff]'
|
||||
|
||||
function reddit:init(config)
|
||||
@@ -18,7 +20,7 @@ local format_results = function(posts)
|
||||
title = utilities.trim(title) .. '...'
|
||||
end
|
||||
local short_url = 'https://redd.it/' .. post.id
|
||||
local s = '[' .. unescape(title) .. '](' .. short_url .. ')'
|
||||
local s = '[' .. encoding(title) .. '](' .. short_url .. ')'
|
||||
if post.domain and not post.is_self and not post.over_18 then
|
||||
s = '`[`[' .. post.domain .. '](' .. post.url:gsub('%)', '\\)') .. ')`]` ' .. s
|
||||
end
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
local reddit_post = {}
|
||||
|
||||
require "./miku/encoding"
|
||||
|
||||
reddit_post.triggers = {
|
||||
"reddit.com/r/([A-Za-z0-9-/-_-.]+)/comments/([A-Za-z0-9-/-_-.]+)"
|
||||
}
|
||||
@@ -19,9 +21,9 @@ function reddit_post:send_reddit_data(data)
|
||||
local author = utilities.md_escape(data[1].data.children[1].data.author)
|
||||
local subreddit = utilities.md_escape(data[1].data.children[1].data.subreddit)
|
||||
if string.len(data[1].data.children[1].data.selftext) > 300 then
|
||||
selftext = string.sub(unescape(data[1].data.children[1].data.selftext:gsub("%b<>", "")), 1, 300) .. '...'
|
||||
selftext = string.sub(encoding(data[1].data.children[1].data.selftext:gsub("%b<>", "")), 1, 300) .. '...'
|
||||
else
|
||||
selftext = unescape(data[1].data.children[1].data.selftext:gsub("%b<>", ""))
|
||||
selftext = encoding(data[1].data.children[1].data.selftext:gsub("%b<>", ""))
|
||||
end
|
||||
if not data[1].data.children[1].data.is_self then
|
||||
url = data[1].data.children[1].data.url
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local rss = {}
|
||||
|
||||
local feedparser = require("feedparser")
|
||||
require "./miku/encoding"
|
||||
|
||||
rss.command = 'rss <sub/del>'
|
||||
|
||||
@@ -310,29 +311,29 @@ function rss:cron(self_plz)
|
||||
local subscribers = {}
|
||||
local text = '' -- Send one message per feed with the latest entries
|
||||
for k2, v2 in pairs(newentr) do
|
||||
local title = unescape(v2.title) or 'Kein Titel'
|
||||
local title = encoding(v2.title) or 'Kein Titel'
|
||||
local link = v2.link or v2.id or 'Kein Link'
|
||||
if v2.content then
|
||||
content = v2.content:gsub("%b<>", "")
|
||||
if string.len(v2.content) > 300 then
|
||||
content = unescape(content)
|
||||
content = encoding(content)
|
||||
content = string.sub(content, 1, 300)..'...'
|
||||
else
|
||||
content = unescape(content)
|
||||
content = encoding(content)
|
||||
end
|
||||
elseif v2.summary then
|
||||
content = v2.summary:gsub("%b<>", "")
|
||||
if string.len(v2.summary) > 300 then
|
||||
content = unescape(content)
|
||||
content = encoding(content)
|
||||
content = string.sub(content, 1, 300)..'...'
|
||||
else
|
||||
content = unescape(content)
|
||||
content = encoding(content)
|
||||
end
|
||||
else
|
||||
content = ''
|
||||
end
|
||||
content = cleanRSS(content)
|
||||
text = text..'\n#RSS: <b>'..title..'</b>\n'..utilities.trim(content)..' <a href="'..link..'">Weiterlesen</a>\n'
|
||||
text = text..'\n<b>[</b>#RSS<b>] '..title..'</b>\n'..utilities.trim(content)..' <a href="'..link..'">Weiterlesen</a>\n'
|
||||
end
|
||||
if text ~= '' then
|
||||
local newlast = newentr[1].id
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
local steam = {}
|
||||
|
||||
require "./miku/encoding"
|
||||
|
||||
steam.triggers = {
|
||||
"store.steampowered.com/app/([0-9]+)",
|
||||
"steamcommunity.com/app/([0-9]+)"
|
||||
@@ -36,7 +38,7 @@ function steam:price_info(data)
|
||||
end
|
||||
|
||||
function steam:send_steam_data(data, self, msg)
|
||||
local description = string.sub(unescape(data.about_the_game:gsub("%b<>", "")), 1, DESC_LENTH) .. '...'
|
||||
local description = string.sub(encoding(data.about_the_game:gsub("%b<>", "")), 1, DESC_LENTH) .. '...'
|
||||
local title = data.name
|
||||
local price = steam:price_info(data.price_overview)
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
local tweet = {}
|
||||
|
||||
require "./miku/encoding"
|
||||
|
||||
function tweet:init(config)
|
||||
if not cred_data.tw_consumer_key then
|
||||
print('Fehlender Key: tw_consumer_key.')
|
||||
@@ -75,7 +77,7 @@ function tweet:analyze_tweet(tweet)
|
||||
table.insert(urls, v.media_url)
|
||||
end
|
||||
text = text:gsub(v.url, "") -- Replace the URL in text
|
||||
text = unescape(text)
|
||||
text = encoding(text)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -125,7 +127,7 @@ end
|
||||
function tweet:sendTweet(self, msg, tweet)
|
||||
local header, text, urls = tweet:analyze_tweet(tweet)
|
||||
-- send the parts
|
||||
local text = unescape(text)
|
||||
local text = encoding(text)
|
||||
send_reply(self, msg, header .. "\n" .. text)
|
||||
tweet:send_all_files(self, msg, urls)
|
||||
return nil
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
local twitter_send = {}
|
||||
|
||||
require "./miku/encoding"
|
||||
|
||||
function twitter_send:init(config)
|
||||
if not cred_data.tw_consumer_key then
|
||||
print('Fehlender Key: tw_consumer_key.')
|
||||
@@ -158,7 +160,7 @@ function twitter_send:twitter_verify_credentials(oauth_token, oauth_token_secret
|
||||
end
|
||||
local header = full_name.. " (@" ..user_name.. ")\n"
|
||||
|
||||
local description = unescape(response.description)
|
||||
local description = encoding(response.description)
|
||||
if response.location then
|
||||
location = response.location
|
||||
else
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
local twitter_user = {}
|
||||
|
||||
require "./miku/encoding"
|
||||
|
||||
function twitter_user:init(config)
|
||||
if not cred_data.tw_consumer_key then
|
||||
print('Fehlender Key: tw_consumer_key.')
|
||||
@@ -72,7 +74,7 @@ function twitter_user:action(msg)
|
||||
end
|
||||
local header = full_name.. " (@" ..user_name.. ")\n"
|
||||
|
||||
local description = unescape(response.description)
|
||||
local description = encoding(response.description)
|
||||
if response.location then
|
||||
location = response.location
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user