Packe "function unescape" in encoding.lua

Character encoding extreme!
This commit is contained in:
Akamaru 2016-08-04 20:37:12 +02:00
parent 440926765f
commit 731454382c
11 changed files with 377 additions and 79 deletions

343
miku/encoding.lua Normal file
View File

@ -0,0 +1,343 @@
-- See http://www.ascii.cl/htmlcodes.htm
-- str = string.gsub(str, '', '')
function encoding(str)
-- Symbols
str = string.gsub(str, ' ', ' ') -- space
str = string.gsub(str, '!', '!') -- exclamation point
str = string.gsub(str, '"', '"') -- double quotes
str = string.gsub(str, '"', '"') -- double quotes
str = string.gsub(str, '#', '#') -- number sign
str = string.gsub(str, '$', '$') -- dollar sign
str = string.gsub(str, '%', '%') -- percent sign
str = string.gsub(str, ''', '\'') -- single quote
str = string.gsub(str, '(', '(') -- opening parenthesis
str = string.gsub(str, ')', ')') -- closing parenthesis
str = string.gsub(str, '*', '*') -- asterisk
str = string.gsub(str, '+', '+') -- plus sign
str = string.gsub(str, ',', ',') -- comma
str = string.gsub(str, '-', '-') -- minus sign - hyphen
str = string.gsub(str, '.', '.') -- period
str = string.gsub(str, '/', '/') -- slash
str = string.gsub(str, ':', ':') -- colon
str = string.gsub(str, '&#59;', ';') -- semicolon
str = string.gsub(str, '&#60;', '<') -- less than sign
str = string.gsub(str, '&lt;', '<') -- less than sign
str = string.gsub(str, '&#61;', '=') -- equal sign
str = string.gsub(str, '&#62;', '>') -- greater than sign
str = string.gsub(str, '&gt;', '>') -- greater than sign
str = string.gsub(str, '&#63;', '?') -- question mark
str = string.gsub(str, '&#64;', '@') -- at symbol
str = string.gsub(str, '&#91;', '[') -- opening bracket
str = string.gsub(str, '&#92;', '\\') -- backslash
str = string.gsub(str, '&#93;', ']') -- closing bracket
str = string.gsub(str, '&#94;', '^') -- caret - circumflex
str = string.gsub(str, '&#95;', '_') -- underscore
str = string.gsub(str, '&#96;', '`') -- grave accent
str = string.gsub(str, '&#123;', '{') -- opening brace
str = string.gsub(str, '&#124;', '|') -- vertical bar
str = string.gsub(str, '&#125;', '}') -- closing brace
str = string.gsub(str, '&#126;', '~') -- equivalency sign - tilde
str = string.gsub(str, '&#160;', ' ') -- non-breaking space
str = string.gsub(str, '&nbsp;', ' ') -- non-breaking space
str = string.gsub(str, '&#161;', '¡') -- inverted exclamation mark
str = string.gsub(str, '&iexcl;', '¡') -- inverted exclamation mark
str = string.gsub(str, '&#162;', '¢') -- cent sign
str = string.gsub(str, '&cent;', '¢') -- cent sign
str = string.gsub(str, '&#163;', '£') -- pound sign
str = string.gsub(str, '&pound;', '£') -- pound sign
str = string.gsub(str, '&#164;', '¤') -- currency sign
str = string.gsub(str, '&curren;', '¤') -- currency sign
str = string.gsub(str, '&#165;', '¥') -- yen sign
str = string.gsub(str, '&yen;', '¥') -- yen sign
str = string.gsub(str, '&#166;', '¦') -- broken vertical bar
str = string.gsub(str, '&brvbar;', '¦') -- broken vertical bar
str = string.gsub(str, '&#167;', '§') -- section sign
str = string.gsub(str, '&sect;', '§') -- section sign
str = string.gsub(str, '&#168;', '¨') -- spacing diaeresis - umlaut
str = string.gsub(str, '&uml;', '¨') -- spacing diaeresis - umlaut
str = string.gsub(str, '&#169;', '©') -- copyright sign
str = string.gsub(str, '&copy;', '©') -- copyright sign
str = string.gsub(str, '&#170;', 'ª') -- feminine ordinal indicator
str = string.gsub(str, '&ordf;', 'ª') -- feminine ordinal indicator
str = string.gsub(str, '&#171;', '«') -- left double angle quotes
str = string.gsub(str, '&laquo;', '«') -- left double angle quotes
str = string.gsub(str, '&#172;', '¬') -- not sign
str = string.gsub(str, '&not;', '¬') -- not sign
str = string.gsub(str, '&#173;', '') -- soft hyphen
str = string.gsub(str, '&shy;', '') -- soft hyphen
str = string.gsub(str, '&#174;', '®') -- registered trade mark sign
str = string.gsub(str, '&reg;', '®') -- registered trade mark sign
str = string.gsub(str, '&#175;', '¯') -- spacing macron - overline
str = string.gsub(str, '&macr;', '¯') -- spacing macron - overline
str = string.gsub(str, '&#176;', '°') -- degree sign
str = string.gsub(str, '&deg;', '°') -- degree sign
str = string.gsub(str, '&#177;', '±') -- plus-or-minus sign
str = string.gsub(str, '&plusmn;', '±') -- plus-or-minus sign
str = string.gsub(str, '&#178;', '²') -- superscript two - squared
str = string.gsub(str, '&sup2;', '²') -- superscript two - squared
str = string.gsub(str, '&#179;', '³') -- superscript three - cubed
str = string.gsub(str, '&sup3;', '³') -- superscript three - cubed
str = string.gsub(str, '&#180;', '´') -- acute accent - spacing acute
str = string.gsub(str, '&acute;', '´') -- acute accent - spacing acute
str = string.gsub(str, '&#181;', 'µ') -- micro sign
str = string.gsub(str, '&micro;', 'µ') -- micro sign
str = string.gsub(str, '&#182;', '') -- pilcrow sign - paragraph sign
str = string.gsub(str, '&para;', '') -- pilcrow sign - paragraph sign
str = string.gsub(str, '&#183;', '·') -- middle dot - Georgian comma
str = string.gsub(str, '&middot;', '·') -- middle dot - Georgian comma
str = string.gsub(str, '&#184;', '¸') -- spacing cedilla
str = string.gsub(str, '&cedil;', '¸') -- spacing cedilla
str = string.gsub(str, '&#185;', '¹') -- superscript one
str = string.gsub(str, '&sup1;', '¹') -- superscript one
str = string.gsub(str, '&#186;', 'º') -- masculine ordinal indicator
str = string.gsub(str, '&ordm;', 'º') -- masculine ordinal indicator
str = string.gsub(str, '&#187;', '»') -- right double angle quotes
str = string.gsub(str, '&raquo;', '»') -- right double angle quotes
str = string.gsub(str, '&#188;', '¼') -- fraction one quarter
str = string.gsub(str, '&frac14;', '¼') -- fraction one quarter
str = string.gsub(str, '&#189;', '½') -- fraction one half
str = string.gsub(str, '&frac12;', '½') -- fraction one half
str = string.gsub(str, '&#190;', '¾') -- fraction three quarters
str = string.gsub(str, '&frac34;', '¾') -- fraction three quarters
str = string.gsub(str, '&#191;', '¿') -- inverted question mark
str = string.gsub(str, '&iquest;', '¿') -- inverted question mark
str = string.gsub(str, '&#215;', '×') -- multiplication sign
str = string.gsub(str, '&times;', '×') -- multiplication sign
str = string.gsub(str, '&#247;', '÷') -- division sign
str = string.gsub(str, '&divide;', '÷') -- division sign
str = string.gsub(str, '&#8211;', '') -- en dash
str = string.gsub(str, '&ndash;', '') -- en dash
str = string.gsub(str, '&#8212;', '') -- em dash
str = string.gsub(str, '&mdash;', '') -- em dash
str = string.gsub(str, '&#8216;', '') -- left single quotation mark
str = string.gsub(str, '&lsquo;', '') -- left single quotation mark
str = string.gsub(str, '&#8217;', '') -- right single quotation mark
str = string.gsub(str, '&rsquo;', '') -- right single quotation mark
str = string.gsub(str, '&#8218;', '') -- single low-9 quotation mark
str = string.gsub(str, '&sbquo;', '') -- single low-9 quotation mark
str = string.gsub(str, '&#8220;', '') -- left double quotation mark
str = string.gsub(str, '&ldquo;', '') -- left double quotation mark
str = string.gsub(str, '&#8221;', '') -- right double quotation mark
str = string.gsub(str, '&#8222;', '') -- double low-9 quotation mark
str = string.gsub(str, '&bdquo;', '') -- double low-9 quotation mark
str = string.gsub(str, '&#8224;', '') -- dagger
str = string.gsub(str, '&#8225;', '') -- double dagger
str = string.gsub(str, '&#8226;', '') -- bullet
str = string.gsub(str, '&#8230;', '') -- horizontal ellipsis
str = string.gsub(str, '&#8240;', '') -- per thousand sign
str = string.gsub(str, '&#8264;', '') -- euro sign
str = string.gsub(str, '&euro;', '') -- euro sign
str = string.gsub(str, '&#8282;', '') -- trade mark sign
-- Numbers
str = string.gsub(str, '&#48;', '0') -- zero
str = string.gsub(str, '&#49;', '1') -- one
str = string.gsub(str, '&#50;', '2') -- two
str = string.gsub(str, '&#51;', '3') -- three
str = string.gsub(str, '&#52;', '4') -- four
str = string.gsub(str, '&#53;', '5') -- five
str = string.gsub(str, '&#54;', '6') -- six
str = string.gsub(str, '&#55;', '7') -- seven
str = string.gsub(str, '&#56;', '8') -- eight
str = string.gsub(str, '&#57;', '9') -- nine
-- Big letters
str = string.gsub(str, '&#65;', 'A')
str = string.gsub(str, '&#66;', 'B')
str = string.gsub(str, '&#67;', 'C')
str = string.gsub(str, '&#68;', 'D')
str = string.gsub(str, '&#69;', 'E')
str = string.gsub(str, '&#70;', 'F')
str = string.gsub(str, '&#71;', 'G')
str = string.gsub(str, '&#72;', 'H')
str = string.gsub(str, '&#73;', 'I')
str = string.gsub(str, '&#74;', 'J')
str = string.gsub(str, '&#75;', 'K')
str = string.gsub(str, '&#76;', 'L')
str = string.gsub(str, '&#77;', 'M')
str = string.gsub(str, '&#78;', 'N')
str = string.gsub(str, '&#79;', 'O')
str = string.gsub(str, '&#80;', 'P')
str = string.gsub(str, '&#81;', 'Q')
str = string.gsub(str, '&#82;', 'R')
str = string.gsub(str, '&#83;', 'S')
str = string.gsub(str, '&#84;', 'T')
str = string.gsub(str, '&#85;', 'U')
str = string.gsub(str, '&#86;', 'V')
str = string.gsub(str, '&#87;', 'W')
str = string.gsub(str, '&#88;', 'X')
str = string.gsub(str, '&#89;', 'Y')
str = string.gsub(str, '&#90;', 'Z')
-- Small letters
str = string.gsub(str, '&#97;', 'a')
str = string.gsub(str, '&#98;', 'b')
str = string.gsub(str, '&#99;', 'c')
str = string.gsub(str, '&#100;', 'd')
str = string.gsub(str, '&#101;', 'e')
str = string.gsub(str, '&#102;', 'f')
str = string.gsub(str, '&#103;', 'g')
str = string.gsub(str, '&#104;', 'h')
str = string.gsub(str, '&#105;', 'i')
str = string.gsub(str, '&#106;', 'j')
str = string.gsub(str, '&#107;', 'k')
str = string.gsub(str, '&#108;', 'l')
str = string.gsub(str, '&#109;', 'm')
str = string.gsub(str, '&#110;', 'n')
str = string.gsub(str, '&#111;', 'o')
str = string.gsub(str, '&#112;', 'p')
str = string.gsub(str, '&#113;', 'q')
str = string.gsub(str, '&#114;', 'r')
str = string.gsub(str, '&#115;', 's')
str = string.gsub(str, '&#116;', 't')
str = string.gsub(str, '&#117;', 'u')
str = string.gsub(str, '&#118;', 'v')
str = string.gsub(str, '&#119;', 'w')
str = string.gsub(str, '&#120;', 'x')
str = string.gsub(str, '&#121;', 'y')
str = string.gsub(str, '&#122;', 'z')
-- Latin capital letters
str = string.gsub(str, '&#192;', 'À') -- latin capital letter A with grave
str = string.gsub(str, '&Agrave;', 'À') -- latin capital letter A with grave
str = string.gsub(str, '&#193;', 'Á') -- latin capital letter A with acute
str = string.gsub(str, '&Aacute;', 'Á') -- latin capital letter A with acute
str = string.gsub(str, '&#194;', 'Â') -- latin capital letter A with circumflex
str = string.gsub(str, '&Acirc;', 'Â') -- latin capital letter A with circumflex
str = string.gsub(str, '&#195;', 'Ã') -- latin capital letter A with tilde
str = string.gsub(str, '&Atilde;', 'Ã') -- latin capital letter A with tilde
str = string.gsub(str, '&#196;', 'Ä') -- latin capital letter A with diaeresis
str = string.gsub(str, '&Auml;', 'Ä') -- latin capital letter A with diaeresis
str = string.gsub(str, '&#197;', 'Å') -- latin capital letter A with ring above
str = string.gsub(str, '&Aring;', 'Å') -- latin capital letter A with ring above
str = string.gsub(str, '&#198;', 'Æ') -- latin capital letter AE
str = string.gsub(str, '&AElig;', 'Æ') -- latin capital letter AE
str = string.gsub(str, '&#199;', 'Ç') -- latin capital letter C with cedilla
str = string.gsub(str, '&Ccedil;', 'Ç') -- latin capital letter C with cedilla
str = string.gsub(str, '&#200;', 'È') -- latin capital letter E with grave
str = string.gsub(str, '&Egrave;', 'È') -- latin capital letter E with grave
str = string.gsub(str, '&#201;', 'É') -- latin capital letter E with acute
str = string.gsub(str, '&Eacute;', 'É') -- latin capital letter E with acute
str = string.gsub(str, '&#202;', 'Ê') -- latin capital letter E with circumflex
str = string.gsub(str, '&Ecirc;', 'Ê') -- latin capital letter E with circumflex
str = string.gsub(str, '&#203;', 'Ë') -- latin capital letter E with diaeresis
str = string.gsub(str, '&Euml;', 'Ë') -- latin capital letter E with diaeresis
str = string.gsub(str, '&#204;', 'Ì') -- latin capital letter I with grave
str = string.gsub(str, '&Igrave;', 'Ì') -- latin capital letter I with grave
str = string.gsub(str, '&#205;', 'Í') -- latin capital letter I with acute
str = string.gsub(str, '&Iacute;', 'Í') -- latin capital letter I with acute
str = string.gsub(str, '&#206;', 'Î') -- latin capital letter I with circumflex
str = string.gsub(str, '&Icirc;', 'Î') -- latin capital letter I with circumflex
str = string.gsub(str, '&#207;', 'Ï') -- latin capital letter I with diaeresis
str = string.gsub(str, '&Iuml;', 'Ï') -- latin capital letter I with diaeresis
str = string.gsub(str, '&#208;', 'Ð') -- latin capital letter ETH
str = string.gsub(str, '&ETH;', 'Ð') -- latin capital letter ETH
str = string.gsub(str, '&#209;', 'Ñ') -- latin capital letter N with tilde
str = string.gsub(str, '&Ntilde;', 'Ñ') -- latin capital letter N with tilde
str = string.gsub(str, '&#210;', 'Ò') -- latin capital letter O with grave
str = string.gsub(str, '&Ograve;', 'Ò') -- latin capital letter O with grave
str = string.gsub(str, '&#211;', 'Ó') -- latin capital letter O with acute
str = string.gsub(str, '&Oacute;', 'Ó') -- latin capital letter O with acute
str = string.gsub(str, '&#212;', 'Ô') -- latin capital letter O with circumflex
str = string.gsub(str, '&Ocrc;', 'Ô') -- latin capital letter O with circumflex
str = string.gsub(str, '&#213;', 'Õ') -- latin capital letter O with tilde
str = string.gsub(str, '&Otilde;', 'Õ') -- latin capital letter O with tilde
str = string.gsub(str, '&#214;', 'Ö') -- latin capital letter O with diaeresis
str = string.gsub(str, '&Ouml;', 'Ö') -- latin capital letter O with diaeresis
str = string.gsub(str, '&#216;', 'Ø') -- latin capital letter O with slash
str = string.gsub(str, '&Oslash;', 'Ø') -- latin capital letter O with slash
str = string.gsub(str, '&#217;', 'Ù') -- latin capital letter U with grave
str = string.gsub(str, '&Ugrave;', 'Ù') -- latin capital letter U with grave
str = string.gsub(str, '&#218;', 'Ú') -- latin capital letter U with acute
str = string.gsub(str, '&Uacute;', 'Ú') -- latin capital letter U with acute
str = string.gsub(str, '&#219;', 'Û') -- latin capital letter U with circumflex
str = string.gsub(str, '&Ucirc;', 'Û') -- latin capital letter U with circumflex
str = string.gsub(str, '&#220;', 'Ü') -- latin capital letter U with diaeresis
str = string.gsub(str, '&Uuml;', 'Ü') -- latin capital letter U with diaeresis
str = string.gsub(str, '&#221;', 'Ý') -- latin capital letter Y with acute
str = string.gsub(str, '&Yacute;', 'Ý') -- latin capital letter Y with acute
str = string.gsub(str, '&#222;', 'Þ') -- latin capital letter THORN
str = string.gsub(str, '&THORN;', 'Þ') -- latin capital letter THORN
str = string.gsub(str, '&#338;', 'Œ') -- latin capital letter OE
str = string.gsub(str, '&#352;', 'Š') -- latin capital letter S with caron
str = string.gsub(str, '&#376;', 'Ÿ') -- latin capital letter Y with diaeresis
-- Latin small letters
str = string.gsub(str, '&#223;', 'ß') -- latin small letter sharp s - ess-zed
str = string.gsub(str, '&szlig;', 'ß') -- latin small letter sharp s - ess-zed
str = string.gsub(str, '&#224;', 'à') -- latin small letter a with grave
str = string.gsub(str, '&agrave;', 'à') -- latin small letter a with grave
str = string.gsub(str, '&#225;', 'á') -- latin small letter a with acute
str = string.gsub(str, '&aacute;', 'á') -- latin small letter a with acute
str = string.gsub(str, '&#226;', 'â') -- latin small letter a with circumflex
str = string.gsub(str, '&acirc;', 'â') -- latin small letter a with circumflex
str = string.gsub(str, '&#227;', 'ã') -- latin small letter a with tilde
str = string.gsub(str, '&atilde;', 'ã') -- latin small letter a with tilde
str = string.gsub(str, '&#228;', 'ä') -- latin small letter a with diaeresis
str = string.gsub(str, '&auml;', 'ä') -- latin small letter a with diaeresis
str = string.gsub(str, '&#229;', 'å') -- latin small letter a with ring above
str = string.gsub(str, '&aring;', 'å') -- latin small letter a with ring above
str = string.gsub(str, '&#230;', 'æ') -- latin small letter ae
str = string.gsub(str, '&aelig;', 'æ') -- latin small letter ae
str = string.gsub(str, '&#231;', 'ç') -- latin small letter c with cedilla
str = string.gsub(str, '&ccedil;', 'ç') -- latin small letter c with cedilla
str = string.gsub(str, '&#232;', 'è') -- latin small letter e with grave
str = string.gsub(str, '&egrave;', 'è') -- latin small letter e with grave
str = string.gsub(str, '&#233;', 'é') -- latin small letter e with acute
str = string.gsub(str, '&eacute;', 'é') -- latin small letter e with acute
str = string.gsub(str, '&#234;', 'ê') -- latin small letter e with circumflex
str = string.gsub(str, '&ecirc;', 'ê') -- latin small letter e with circumflex
str = string.gsub(str, '&#235;', 'ë') -- latin small letter e with diaeresis
str = string.gsub(str, '&euml;', 'ë') -- latin small letter e with diaeresis
str = string.gsub(str, '&#236;', 'ì') -- latin small letter i with grave
str = string.gsub(str, '&igrave;', 'ì') -- latin small letter i with grave
str = string.gsub(str, '&#237;', 'í') -- latin small letter i with acute
str = string.gsub(str, '&iacute;', 'í') -- latin small letter i with acute
str = string.gsub(str, '&#238;', 'î') -- latin small letter i with circumflex
str = string.gsub(str, '&icirc;', 'î') -- latin small letter i with circumflex
str = string.gsub(str, '&#239;', 'ï') -- latin small letter i with diaeresis
str = string.gsub(str, '&iuml;', 'ï') -- latin small letter i with diaeresis
str = string.gsub(str, '&#240;', 'ð') -- latin small letter eth
str = string.gsub(str, '&eth;', 'ð') -- latin small letter eth
str = string.gsub(str, '&#241;', 'ñ') -- latin small letter n with tilde
str = string.gsub(str, '&ntilde;', 'ñ') -- latin small letter n with tilde
str = string.gsub(str, '&#242;', 'ò') -- latin small letter o with grave
str = string.gsub(str, '&ograve;', 'ò') -- latin small letter o with grave
str = string.gsub(str, '&#243;', 'ó') -- latin small letter o with acute
str = string.gsub(str, '&oacute;', 'ó') -- latin small letter o with acute
str = string.gsub(str, '&#244;', 'ô') -- latin small letter o with circumflex
str = string.gsub(str, '&ocirc;', 'ô') -- latin small letter o with circumflex
str = string.gsub(str, '&#245;', 'õ') -- latin small letter o with tilde
str = string.gsub(str, '&otilde;', 'õ') -- latin small letter o with tilde
str = string.gsub(str, '&#246;', 'ö') -- latin small letter o with diaeresis
str = string.gsub(str, '&ouml;', 'ö') -- latin small letter o with diaeresis
str = string.gsub(str, '&#248;', 'ø') -- latin small letter o with slash
str = string.gsub(str, '&oslash;', 'ø') -- latin small letter o with slash
str = string.gsub(str, '&#249;', 'ù') -- latin small letter u with grave
str = string.gsub(str, '&ugrave;', 'ù') -- latin small letter u with grave
str = string.gsub(str, '&#250;', 'ú') -- latin small letter u with acute
str = string.gsub(str, '&uacute;', 'ú') -- latin small letter u with acute
str = string.gsub(str, '&#251;', 'û') -- latin small letter u with circumflex
str = string.gsub(str, '&ucirc;', 'û') -- latin small letter u with circumflex
str = string.gsub(str, '&#252;', 'ü') -- latin small letter u with diaeresis
str = string.gsub(str, '&uuml;', 'ü') -- latin small letter u with diaeresis
str = string.gsub(str, '&#253;', 'ý') -- latin small letter y with acute
str = string.gsub(str, '&yacute;', 'ý') -- latin small letter y with acute
str = string.gsub(str, '&#254;', 'þ') -- latin small letter thorn
str = string.gsub(str, '&thorn;', 'þ') -- latin small letter thorn
str = string.gsub(str, '&#255;', 'ÿ') -- latin small letter y with diaeresis
str = string.gsub(str, '&yuml;', 'ÿ') -- latin small letter y with diaeresis
str = string.gsub(str, '&#339;', 'œ') -- latin small letter oe
str = string.gsub(str, '&#353;', 'š') -- latin small letter s with caron
str = string.gsub(str, '&#402;', 'ƒ') -- latin small f with hook - function
-- Emoticons (more soon)
str = string.gsub(str, '&#11088;&#65039;', '⭐️')
-- Be sure to do this after all others
str = string.gsub(str, '&#38;', '&') -- amper sand
str = string.gsub(str, '&amp;', '&') -- amper sand
return str
end

View File

@ -1,5 +1,7 @@
local app_store = {} local app_store = {}
require "./miku/encoding"
app_store.triggers = { app_store.triggers = {
"itunes.apple.com/(.*)/app/(.*)/id(%d+)", "itunes.apple.com/(.*)/app/(.*)/id(%d+)",
"^/[Ii][Tt][Uu][Nn][Ee][Ss] (%d+)$", "^/[Ii][Tt][Uu][Nn][Ee][Ss] (%d+)$",
@ -34,7 +36,7 @@ function app_store:send_appstore_data(data)
local version = data.version local version = data.version
-- Body -- 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 min_ios_ver = data.minimumOsVersion
local size = string.gsub(round(data.fileSizeBytes / 1000000, 2), "%.", ",") -- wtf Apple, it's 1024, not 1000! local size = string.gsub(round(data.fileSizeBytes / 1000000, 2), "%.", ",") -- wtf Apple, it's 1024, not 1000!
local release = makeOurDate(data.releaseDate) local release = makeOurDate(data.releaseDate)

View File

@ -1,6 +1,7 @@
local mal = {} local mal = {}
local xml = require("xml") local xml = require("xml")
require "./miku/encoding"
mal.command = 'anime <Anime>, /manga <Manga>' mal.command = 'anime <Anime>, /manga <Manga>'
@ -117,7 +118,7 @@ function mal:send_anime_data(result, receiver)
end end
if xml.find(result, 'synopsis')[1] then 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 else
desc = '' desc = ''
end end
@ -144,7 +145,7 @@ function mal:send_manga_data(result)
end end
if xml.find(result, 'synonyms')[1] then 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 else
alt_name = '' alt_name = ''
end end
@ -186,7 +187,7 @@ function mal:send_manga_data(result)
end end
if xml.find(result, 'synopsis')[1] then 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 else
desc = '' desc = ''
end end

View File

@ -1,5 +1,7 @@
local reddit = {} local reddit = {}
require "./miku/encoding"
reddit.command = 'reddit [r/subreddit | Suchbegriff]' reddit.command = 'reddit [r/subreddit | Suchbegriff]'
function reddit:init(config) function reddit:init(config)
@ -18,7 +20,7 @@ local format_results = function(posts)
title = utilities.trim(title) .. '...' title = utilities.trim(title) .. '...'
end end
local short_url = 'https://redd.it/' .. post.id 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 if post.domain and not post.is_self and not post.over_18 then
s = '`[`[' .. post.domain .. '](' .. post.url:gsub('%)', '\\)') .. ')`]` ' .. s s = '`[`[' .. post.domain .. '](' .. post.url:gsub('%)', '\\)') .. ')`]` ' .. s
end end

View File

@ -1,5 +1,7 @@
local reddit_post = {} local reddit_post = {}
require "./miku/encoding"
reddit_post.triggers = { reddit_post.triggers = {
"reddit.com/r/([A-Za-z0-9-/-_-.]+)/comments/([A-Za-z0-9-/-_-.]+)" "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 author = utilities.md_escape(data[1].data.children[1].data.author)
local subreddit = utilities.md_escape(data[1].data.children[1].data.subreddit) local subreddit = utilities.md_escape(data[1].data.children[1].data.subreddit)
if string.len(data[1].data.children[1].data.selftext) > 300 then 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 else
selftext = unescape(data[1].data.children[1].data.selftext:gsub("%b<>", "")) selftext = encoding(data[1].data.children[1].data.selftext:gsub("%b<>", ""))
end end
if not data[1].data.children[1].data.is_self then if not data[1].data.children[1].data.is_self then
url = data[1].data.children[1].data.url url = data[1].data.children[1].data.url

View File

@ -1,6 +1,7 @@
local rss = {} local rss = {}
local feedparser = require("feedparser") local feedparser = require("feedparser")
require "./miku/encoding"
rss.command = 'rss <sub/del>' rss.command = 'rss <sub/del>'
@ -310,29 +311,29 @@ function rss:cron(self_plz)
local subscribers = {} local subscribers = {}
local text = '' -- Send one message per feed with the latest entries local text = '' -- Send one message per feed with the latest entries
for k2, v2 in pairs(newentr) do 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' local link = v2.link or v2.id or 'Kein Link'
if v2.content then if v2.content then
content = v2.content:gsub("%b<>", "") content = v2.content:gsub("%b<>", "")
if string.len(v2.content) > 300 then if string.len(v2.content) > 300 then
content = unescape(content) content = encoding(content)
content = string.sub(content, 1, 300)..'...' content = string.sub(content, 1, 300)..'...'
else else
content = unescape(content) content = encoding(content)
end end
elseif v2.summary then elseif v2.summary then
content = v2.summary:gsub("%b<>", "") content = v2.summary:gsub("%b<>", "")
if string.len(v2.summary) > 300 then if string.len(v2.summary) > 300 then
content = unescape(content) content = encoding(content)
content = string.sub(content, 1, 300)..'...' content = string.sub(content, 1, 300)..'...'
else else
content = unescape(content) content = encoding(content)
end end
else else
content = '' content = ''
end end
content = cleanRSS(content) 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 end
if text ~= '' then if text ~= '' then
local newlast = newentr[1].id local newlast = newentr[1].id

View File

@ -1,5 +1,7 @@
local steam = {} local steam = {}
require "./miku/encoding"
steam.triggers = { steam.triggers = {
"store.steampowered.com/app/([0-9]+)", "store.steampowered.com/app/([0-9]+)",
"steamcommunity.com/app/([0-9]+)" "steamcommunity.com/app/([0-9]+)"
@ -36,7 +38,7 @@ function steam:price_info(data)
end end
function steam:send_steam_data(data, self, msg) 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 title = data.name
local price = steam:price_info(data.price_overview) local price = steam:price_info(data.price_overview)

View File

@ -1,5 +1,7 @@
local tweet = {} local tweet = {}
require "./miku/encoding"
function tweet:init(config) function tweet:init(config)
if not cred_data.tw_consumer_key then if not cred_data.tw_consumer_key then
print('Fehlender Key: tw_consumer_key.') print('Fehlender Key: tw_consumer_key.')
@ -75,7 +77,7 @@ function tweet:analyze_tweet(tweet)
table.insert(urls, v.media_url) table.insert(urls, v.media_url)
end end
text = text:gsub(v.url, "") -- Replace the URL in text text = text:gsub(v.url, "") -- Replace the URL in text
text = unescape(text) text = encoding(text)
end end
end end
@ -125,7 +127,7 @@ end
function tweet:sendTweet(self, msg, tweet) function tweet:sendTweet(self, msg, tweet)
local header, text, urls = tweet:analyze_tweet(tweet) local header, text, urls = tweet:analyze_tweet(tweet)
-- send the parts -- send the parts
local text = unescape(text) local text = encoding(text)
send_reply(self, msg, header .. "\n" .. text) send_reply(self, msg, header .. "\n" .. text)
tweet:send_all_files(self, msg, urls) tweet:send_all_files(self, msg, urls)
return nil return nil

View File

@ -1,5 +1,7 @@
local twitter_send = {} local twitter_send = {}
require "./miku/encoding"
function twitter_send:init(config) function twitter_send:init(config)
if not cred_data.tw_consumer_key then if not cred_data.tw_consumer_key then
print('Fehlender Key: tw_consumer_key.') print('Fehlender Key: tw_consumer_key.')
@ -158,7 +160,7 @@ function twitter_send:twitter_verify_credentials(oauth_token, oauth_token_secret
end end
local header = full_name.. " (@" ..user_name.. ")\n" local header = full_name.. " (@" ..user_name.. ")\n"
local description = unescape(response.description) local description = encoding(response.description)
if response.location then if response.location then
location = response.location location = response.location
else else

View File

@ -1,5 +1,7 @@
local twitter_user = {} local twitter_user = {}
require "./miku/encoding"
function twitter_user:init(config) function twitter_user:init(config)
if not cred_data.tw_consumer_key then if not cred_data.tw_consumer_key then
print('Fehlender Key: tw_consumer_key.') print('Fehlender Key: tw_consumer_key.')
@ -72,7 +74,7 @@ function twitter_user:action(msg)
end end
local header = full_name.. " (@" ..user_name.. ")\n" local header = full_name.. " (@" ..user_name.. ")\n"
local description = unescape(response.description) local description = encoding(response.description)
if response.location then if response.location then
location = response.location location = response.location
else else

View File

@ -1016,67 +1016,6 @@ function run_sh(msg)
return text return text
end end
function unescape(str)
-- Character encoding
str = string.gsub(str, "&acute;", "´")
str = string.gsub(str, "&bull;", "")
str = string.gsub(str, "&eacute;", "é")
str = string.gsub(str, "&gt;", ">")
str = string.gsub(str, "&hellip;", "")
str = string.gsub(str, "&lt;", "<")
str = string.gsub(str, "&mdash;", "")
str = string.gsub(str, "&nabla;", "")
str = string.gsub(str, "&nbsp;", " ")
str = string.gsub(str, "&ndash;", "")
str = string.gsub(str, "&Psi;", "ψ")
str = string.gsub(str, "&psi;", "ψ")
str = string.gsub(str, "&quot;", '"')
str = string.gsub(str, "&raquo;", "»")
str = string.gsub(str, "&reg;", "®")
str = string.gsub(str, "&szlig;", "ß")
str = string.gsub(str, "&trade;", "")
str = string.gsub(str, "&#038;", "&")
str = string.gsub(str, "&#039;", "'")
str = string.gsub(str, "&#34;", '"')
str = string.gsub(str, "&#39;", "'")
str = string.gsub(str, "&#124;", "|")
str = string.gsub(str, "&#160;", " ")
str = string.gsub(str, "&#174;", "®")
str = string.gsub(str, "&#187;", "»")
str = string.gsub(str, "&#223;", "ß")
str = string.gsub(str, "&#8211;", "")
str = string.gsub(str, "&#8217;", "'")
str = string.gsub(str, "&#8220;", "")
str = string.gsub(str, "&#8221;", "")
str = string.gsub(str, "&#8222;", "")
str = string.gsub(str, "&#8230;", "")
str = string.gsub(str, "&#8249;", "")
str = string.gsub(str, "&#8364;", "")
str = string.gsub(str, "&#9834;", "")
-- Ä Ö Ü
str = string.gsub(str, "&auml;", "ä")
str = string.gsub(str, "&Auml;", "Ä")
str = string.gsub(str, "&#228;", "ä")
str = string.gsub(str, "&#196;", "Ä")
str = string.gsub(str, "&ouml;", "ö")
str = string.gsub(str, "&Ouml;", "Ö")
str = string.gsub(str, "&#246;", "ö")
str = string.gsub(str, "&#214;", "Ö")
str = string.gsub(str, "&uuml;", "ü")
str = string.gsub(str, "&Uuml;", "Ü")
str = string.gsub(str, "&#252;", "ü")
str = string.gsub(str, "&#220;", "Ü")
--emoticons
str = string.gsub(str, "&#11088;&#65039;", "⭐️")
--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, '&amp;', '&' ) -- Be sure to do this after all others
return str
end
function gerRating(str) function gerRating(str)
str = string.gsub(str, "de/0", "FSK0") str = string.gsub(str, "de/0", "FSK0")
str = string.gsub(str, "TV%-G", "FSK0") str = string.gsub(str, "TV%-G", "FSK0")