diff --git a/miku/plugins/afk.lua b/miku/plugins/afk.lua
index 171e0b0..9200c1b 100644
--- a/miku/plugins/afk.lua
+++ b/miku/plugins/afk.lua
@@ -82,11 +82,9 @@ function afk:pre_process(msg, self)
redis:hset(hash, 'afk', false)
if afk_text then
redis:hset(hash, 'afk_text', false)
- local afk_text = afk_text:gsub("%*","")
- local afk_text = afk_text:gsub("_","")
- utilities.send_reply(self, msg, user_name..' ist wieder da! (war: *'..afk_text..'* für '..duration..')', true, '{"hide_keyboard":true,"selective":true}')
+ utilities.send_reply(self, msg, user_name..' ist wieder da! (war: '..afk_text..' für '..duration..')', 'HTML', '{"hide_keyboard":true,"selective":true}')
else
- utilities.send_reply(self, msg, user_name..' ist wieder da! (war '..duration..' weg)', false, '{"hide_keyboard":true,"selective":true}')
+ utilities.send_reply(self, msg, user_name..' ist wieder da! (war '..duration..' weg)', nil, '{"hide_keyboard":true,"selective":true}')
end
end
diff --git a/miku/plugins/app_store.lua b/miku/plugins/app_store.lua
index d2b36a0..5ef13af 100644
--- a/miku/plugins/app_store.lua
+++ b/miku/plugins/app_store.lua
@@ -68,8 +68,8 @@ function app_store:send_appstore_data(data)
end
- local header = '*'..name..'* v'..version..' von *'..author..'* ('..price..'):'
- local body = '\n'..description..'\n_Benötigt mind. iOS '..min_ios_ver..'_\nGröße: '..size..' MB\nErstveröffentlicht am '..release..game_center..category
+ local header = ''..name..' v'..version..' von '..author..' ('..price..'):'
+ local body = '\n'..description..'\nBenötigt mind. iOS '..min_ios_ver..'\nGröße: '..size..' MB\nErstveröffentlicht am '..release..game_center..category
local footer = '\n'..avg_rating..ratings
local text = header..body..footer
@@ -96,11 +96,11 @@ function app_store:action(msg, config, matches)
local data = app_store:get_appstore_data()
if data == nil then print('Das Appstore-Plugin unterstützt nur Apps!') end
if data == 'HTTP-FEHLER' or data == 'NOTFOUND' then
- utilities.send_reply(self, msg, '*App nicht gefunden!*', true)
+ utilities.send_reply(self, msg, 'App nicht gefunden!', 'HTML')
return
else
local output, image_url = app_store:send_appstore_data(data)
- utilities.send_reply(self, msg, output, true)
+ utilities.send_reply(self, msg, output, 'HTML')
if image_url then
utilities.send_typing(self, msg.chat.id, 'upload_photo')
local file = download_to_file(image_url)
diff --git a/miku/plugins/echo.lua b/miku/plugins/echo.lua
index fb07e67..11123c0 100644
--- a/miku/plugins/echo.lua
+++ b/miku/plugins/echo.lua
@@ -21,7 +21,7 @@ function echo:inline_callback(inline_query, config, matches)
results = results..'{"type":"article","id":"'..math.random(100000000000000000)..'","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/echo/custom.jpg","title":"Eigenes Markdown","description":"'..text..'","input_message_content":{"message_text":"'..text..'","parse_mode":"Markdown"}},'
end
- local results = results..'{"type":"article","id":"'..math.random(100000000000000000)..'","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/echo/fett.jpg","title":"Fett","description":"*'..text..'*","input_message_content":{"message_text":"*'..text..'*","parse_mode":"Markdown"}},{"type":"article","id":"'..math.random(100000000000000000)..'","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/echo/kursiv.jpg","title":"Kursiv","description":"_'..text..'_","input_message_content":{"message_text":"_'..text..'_","parse_mode":"Markdown"}},{"type":"article","id":"'..math.random(100000000000000000)..'","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/echo/fixedsys.jpg","title":"Feste Breite","description":"`'..text..'`","input_message_content":{"message_text":"`'..text..'`","parse_mode":"Markdown"}}]'
+ local results = results..'{"type":"article","id":"'..math.random(100000000000000000)..'","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/echo/fett.jpg","title":"Fett","description":"*'..text..'*","input_message_content":{"message_text":"'..text..'","parse_mode":"HTML"}},{"type":"article","id":"'..math.random(100000000000000000)..'","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/echo/kursiv.jpg","title":"Kursiv","description":"_'..text..'_","input_message_content":{"message_text":"'..text..'","parse_mode":"HTML"}},{"type":"article","id":"'..math.random(100000000000000000)..'","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/echo/fixedsys.jpg","title":"Feste Breite","description":"`'..text..'`","input_message_content":{"message_text":"'..text..'
","parse_mode":"HTML"}}]'
utilities.answer_inline_query(self, inline_query, results, 0)
end
diff --git a/miku/plugins/facebook.lua b/miku/plugins/facebook.lua
index ec51012..e7142d1 100644
--- a/miku/plugins/facebook.lua
+++ b/miku/plugins/facebook.lua
@@ -45,7 +45,7 @@ function facebook:fb_post (id, story_id)
local message = data.message
local name = data.name
if data.link then
- link = '\n'..data.name..':\n'..utilities.md_escape(data.link)
+ link = '\n'..data.name..''
else
link = ''
end
@@ -56,7 +56,7 @@ function facebook:fb_post (id, story_id)
story = ''
end
- local text = '*'..from..'*'..story..':\n'..message..'\n'..link
+ local text = ''..from..''..story..':\n'..message..'\n'..link
return text
end
@@ -66,9 +66,9 @@ function facebook:send_facebook_photo(photo_id, receiver)
if code ~= 200 then return nil end
local data = json.decode(res)
- local from = '*'..data.from.name..'*'
+ local from = ''..data.from.name..''
if data.name then
- text = from..' hat ein Bild gepostet:\n'..utilities.md_escape(data.name)
+ text = from..' hat ein Bild gepostet:\n'..data.name
else
text = from..' hat ein Bild gepostet:'
end
@@ -82,7 +82,7 @@ function facebook:send_facebook_video(video_id)
if code ~= 200 then return nil end
local data = json.decode(res)
- local from = '*'..data.from.name..'*'
+ local from = ''..data.from.name..''
local description = data.description or ''
local source = data.source
return from..' hat ein Video gepostet:\n'..description, source, data.title
@@ -123,7 +123,7 @@ function facebook:facebook_info(name)
birth = ''
end
- local text = '*'..name..'* ('..category..')_'..about..'_'..general_info..birth
+ local text = ''..name..' ('..category..')'..about..''..general_info..birth
return text
end
@@ -135,7 +135,7 @@ function facebook:action(msg, config, matches)
else
id = matches[4]
end
- utilities.send_reply(self, msg, facebook:fb_post(id, story_id), true)
+ utilities.send_reply(self, msg, facebook:fb_post(id, story_id), 'HTML')
return
elseif matches[1] == 'photo' or matches[2] == 'photos' then
if not matches[4] then
@@ -147,7 +147,7 @@ function facebook:action(msg, config, matches)
if not image_url then return end
utilities.send_typing(self, msg.chat.id, 'upload_photo')
local file = download_to_file(image_url, 'photo.jpg')
- utilities.send_reply(self, msg, text, true)
+ utilities.send_reply(self, msg, text, 'HTML')
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id)
return
elseif matches[1] == 'video' or matches[2] == 'videos' then
@@ -163,10 +163,10 @@ function facebook:action(msg, config, matches)
title = 'VIDEO: '..title
end
if not video_url then return end
- utilities.send_reply(self, msg, output, true, '{"inline_keyboard":[[{"text":"'..utilities.md_escape(title)..'","url":"'..video_url..'"}]]}')
+ utilities.send_reply(self, msg, output, 'HTML', '{"inline_keyboard":[[{"text":"'..utilities.md_escape(title)..'","url":"'..video_url..'"}]]}')
return
else
- utilities.send_reply(self, msg, facebook:facebook_info(matches[1]), true)
+ utilities.send_reply(self, msg, facebook:facebook_info(matches[1]), 'HTML')
return
end
end
diff --git a/miku/plugins/rss.lua b/miku/plugins/rss.lua
index 95bc8d2..cba6cdf 100644
--- a/miku/plugins/rss.lua
+++ b/miku/plugins/rss.lua
@@ -121,16 +121,6 @@ function get_new_entries(last, nentries)
return entries
end
-function print_subs(id, chat_name)
- local uhash = get_base_redis(id)
- local subs = redis:smembers(uhash)
- local text = '"'..chat_name..'" hat abonniert:\n---------\n'
- for k,v in pairs(subs) do
- text = text .. k .. ") " .. v .. '\n'
- end
- return text
-end
-
function rss:subscribe(id, url)
local baseurl, protocol = prot_url(url)
@@ -140,7 +130,7 @@ function rss:subscribe(id, url)
local uhash = get_base_redis(id)
if redis:sismember(uhash, baseurl) then
- return "Du hast `"..url.."` bereits abonniert."
+ return "Du hast "..url.."
bereits abonniert."
end
local parsed, err = get_rss(url, protocol)
@@ -160,7 +150,7 @@ function rss:subscribe(id, url)
redis:sadd(lhash, id)
redis:sadd(uhash, baseurl)
- return "_"..name.."_ abonniert!"
+ return ""..name.." abonniert!"
end
function rss:unsubscribe(id, n)
@@ -188,18 +178,18 @@ function rss:unsubscribe(id, n)
redis:del(lasthash)
end
- return "Du hast `"..sub.."` deabonniert."
+ return "Du hast "..sub.."
deabonniert."
end
function rss:print_subs(id, chat_name)
local uhash = get_base_redis(id)
local subs = redis:smembers(uhash)
if not subs[1] then
- return 'Keine Feeds abonniert!'
+ return 'Keine Feeds abonniert!'
end
local keyboard = '{"keyboard":[['
local keyboard_buttons = ''
- local text = '*'..chat_name..'* hat abonniert:\n---------\n'
+ local text = ''..chat_name..' hat abonniert:\n---------\n'
for k,v in pairs(subs) do
text = text .. k .. ") " .. v .. '\n'
if k == #subs then
@@ -231,7 +221,7 @@ function rss:action(msg, config, matches)
return
end
local output = rss:subscribe(id, matches[2])
- utilities.send_reply(self, msg, output, true)
+ utilities.send_reply(self, msg, output, 'HTML')
return
elseif matches[1] == 'del' and matches[2] and matches[3] then
if msg.from.id ~= config.admin then
@@ -245,7 +235,7 @@ function rss:action(msg, config, matches)
return
end
local output = rss:unsubscribe(id, matches[2])
- utilities.send_reply(self, msg, output, true)
+ utilities.send_reply(self, msg, output, 'HTML')
return
elseif matches[1] == 'rss' and matches[2] then
local id = '@'..matches[2]
@@ -256,7 +246,7 @@ function rss:action(msg, config, matches)
end
local chat_name = result.result.title
local output = rss:print_subs(id, chat_name)
- utilities.send_reply(self, msg, output, true)
+ utilities.send_reply(self, msg, output, 'HTML')
return
end
@@ -272,7 +262,7 @@ function rss:action(msg, config, matches)
return
end
local output = rss:subscribe(id, matches[2])
- utilities.send_reply(self, msg, output, true)
+ utilities.send_reply(self, msg, output, 'HTML')
return
elseif matches[1] == 'del' and matches[2] then
if msg.from.id ~= config.admin then
@@ -280,11 +270,11 @@ function rss:action(msg, config, matches)
return
end
local output = rss:unsubscribe(id, matches[2])
- utilities.send_reply(self, msg, output, true, '{"hide_keyboard":true}')
+ utilities.send_reply(self, msg, output, 'HTML', '{"hide_keyboard":true}')
return
elseif matches[1] == 'del' and not matches[2] then
local list_subs, keyboard = rss:print_subs(id, chat_name)
- utilities.send_reply(self, msg, list_subs, true, keyboard)
+ utilities.send_reply(self, msg, list_subs, 'HTML', keyboard)
return
elseif matches[1] == 'sync' then
if msg.from.id ~= config.admin then
@@ -296,7 +286,7 @@ function rss:action(msg, config, matches)
end
local output = rss:print_subs(id, chat_name)
- utilities.send_reply(self, msg, output, true)
+ utilities.send_reply(self, msg, output, 'HTML')
return
end
@@ -342,7 +332,7 @@ function rss:cron(self_plz)
content = ''
end
content = cleanRSS(content)
- text = text..'\n*[*#RSS*] '..title..'*\n'..utilities.trim(utilities.md_escape(content))..' [Weiterlesen]('..link..')\n'
+ text = text..'\n#RSS: '..title..'\n'..utilities.trim(content)..' Weiterlesen\n'
end
if text ~= '' then
local newlast = newentr[1].id
@@ -350,7 +340,7 @@ function rss:cron(self_plz)
for k2, receiver in pairs(redis:smembers(v)) do
local receiver = string.gsub(receiver, 'chat%#id', '')
local receiver = string.gsub(receiver, 'user%#id', '')
- utilities.send_message(self, receiver, text, true, nil, true)
+ utilities.send_message(self, receiver, text, true, nil, 'HTML')
end
end
end
diff --git a/miku/plugins/service_entergroup.lua b/miku/plugins/service_entergroup.lua
index 2a05844..079930d 100644
--- a/miku/plugins/service_entergroup.lua
+++ b/miku/plugins/service_entergroup.lua
@@ -21,8 +21,8 @@ function entergroup:chat_new_user(msg, self)
if msg.new_chat_member.id == self.info.id then -- don't say hello to ourselves
return
end
- local text = 'Hallo '..user_name..', willkommen bei *'..chat_title..'*!'..added_by
- utilities.send_reply(self, msg, text, true)
+ local text = 'Hallo '..user_name..', willkommen bei '..chat_title..'!'..added_by
+ utilities.send_reply(self, msg, text, 'HTML')
end
function entergroup:chat_del_user(msg, self)
@@ -35,8 +35,8 @@ function entergroup:chat_del_user(msg, self)
else
at_name = ''
end
- local text = user_name..' wurde von '..msg.from.first_name..at_name..' aus der Gruppe gekickt.'
- utilities.send_reply(self, msg, text, true)
+ local text = ''..user_name..' wurde von '..msg.from.first_name..''..at_name..' aus der Gruppe gekickt.'
+ utilities.send_reply(self, msg, text, 'HTML')
end
function entergroup:action(msg, config, matches)
diff --git a/miku/plugins/shell.lua b/miku/plugins/shell.lua
index 4399c26..11b4964 100644
--- a/miku/plugins/shell.lua
+++ b/miku/plugins/shell.lua
@@ -5,28 +5,27 @@ function shell:init(config)
end
function shell:action(msg, config)
+ if not is_sudo(msg, config) then
+ utilities.send_reply(self, msg, config.errors.sudo)
+ return
+ end
- if msg.from.id ~= config.admin then
- utilities.send_reply(self, msg, config.errors.sudo)
- return
- end
-
- local input = utilities.input(msg.text)
- input = input:gsub('—', '--')
-
- if not input then
- utilities.send_reply(self, msg, 'Bitte gebe ein Kommando ein.')
- return
- end
-
- local output = io.popen(input):read('*all')
- if output:len() == 0 then
- output = 'Ausgeführt.'
- else
- output = '```\n' .. output .. '\n```'
- end
- utilities.send_message(self, msg.chat.id, output, true, msg.message_id, true)
+ local input = utilities.input(msg.text)
+ if not input then
+ utilities.send_reply(self, msg, 'Bitte gib ein Kommando ein.')
+ return
+ end
+ input = input:gsub('—', '--')
+ local output = run_command(input)
+ if output:len() == 0 then
+ output = 'Ausgeführt.'
+ else
+ output = '
\n' .. output .. '\n' + end + output = output:gsub('
%\n', '') + utilities.send_message(self, msg.chat.id, output, true, msg.message_id, 'HTML') end -return shell +return shell \ No newline at end of file diff --git a/miku/plugins/tagesschau.lua b/miku/plugins/tagesschau.lua index 24a5494..f6da7ab 100644 --- a/miku/plugins/tagesschau.lua +++ b/miku/plugins/tagesschau.lua @@ -30,7 +30,7 @@ function tagesschau:get_tagesschau_article(article) local news = data.shorttext local posted_at = makeOurDate(data.date)..' Uhr' - local text = '*'..title..'*\n_'..posted_at..'_\n'..news + local text = ''..title..'\n'..posted_at..'\n'..news if data.banner[1] then return text, data.banner[1].variants[1].modPremium, data.shortheadline, data.shorttext else @@ -55,7 +55,7 @@ function tagesschau:inline_callback(inline_query, config, matches) end local text = text:gsub('\n', '\\n') - local results = '[{"type":"article","id":"'..math.random(100000000000000000)..'","title":"'..headline..'","description":"'..shorttext..'","url":"'..full_url..'","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/tagesschau/tagesschau.jpg","thumb_width":150,"thumb_height":150,"hide_url":true,"reply_markup":{"inline_keyboard":[[{"text":"Artikel aufrufen","url":"'..full_url..'"}]]},"input_message_content":{"message_text":"'..text..'","parse_mode":"Markdown"}}]' + local results = '[{"type":"article","id":"'..math.random(100000000000000000)..'","title":"'..headline..'","description":"'..shorttext..'","url":"'..full_url..'","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/tagesschau/tagesschau.jpg","thumb_width":150,"thumb_height":150,"hide_url":true,"reply_markup":{"inline_keyboard":[[{"text":"Artikel aufrufen","url":"'..full_url..'"}]]},"input_message_content":{"message_text":"'..text..'","parse_mode":"HTML"}}]' utilities.answer_inline_query(self, inline_query, results, 7200) end @@ -67,7 +67,7 @@ function tagesschau:action(msg, config, matches) local file = download_to_file(image_url) utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id) end - utilities.send_reply(self, msg, text, true) + utilities.send_reply(self, msg, text, 'HTML') end return tagesschau \ No newline at end of file diff --git a/miku/plugins/twitter.lua b/miku/plugins/twitter.lua index 1902c6a..19b1987 100644 --- a/miku/plugins/twitter.lua +++ b/miku/plugins/twitter.lua @@ -2,20 +2,20 @@ local twitter = {} function twitter:init(config) if not cred_data.tw_consumer_key then - print('Fehlender Key: tw_consumer_key.') - print('twitter.lua wird nicht aktiviert.') + print('Missing config value: tw_consumer_key.') + print('twitter.lua will not be enabled.') return elseif not cred_data.tw_consumer_secret then - print('Fehlender Key: tw_consumer_secret.') - print('twitter.lua wird nicht aktiviert.') + print('Missing config value: tw_consumer_secret.') + print('twitter.lua will not be enabled.') return elseif not cred_data.tw_access_token then - print('Fehlender Key: tw_access_token.') - print('twitter.lua wird nicht aktiviert.') + print('Missing config value: tw_access_token.') + print('twitter.lua will not be enabled.') return elseif not cred_data.tw_access_token_secret then - print('Fehlender Key: tw_access_token_secret.') - print('twitter.lua wird nicht aktiviert.') + print('Missing config value: tw_access_token_secret.') + print('twitter.lua will not be enabled.') return end @@ -59,8 +59,7 @@ function twitter:action(msg, config, matches) else verified = '' end - -- MD: local header = 'Tweet von '..full_name..' ([@' ..user_name.. '](https://twitter.com/'..user_name..')'..verified..')\n' - local header = 'Tweet von '..full_name..' (@' ..user_name..verified..')\n' + local header = 'Tweet von '..full_name..' (@' ..user_name..''..verified..'):' local text = response.text @@ -76,11 +75,11 @@ function twitter:action(msg, config, matches) favorites = response.favorite_count..'x favorisiert' end if retweets == "" and favorites ~= "" then - footer = favorites + footer = ''..favorites..'' elseif retweets ~= "" and favorites == "" then - footer = retweets + footer = ''..retweets..'' elseif retweets ~= "" and favorites ~= "" then - footer = retweets..' - '..favorites + footer = ''..retweets..' - '..favorites..'' else footer = "" end @@ -126,14 +125,13 @@ function twitter:action(msg, config, matches) else quoted_verified = '' end - -- MD: quote = 'Als Antwort auf '..quoted_name..' ([@' ..quoted_screen_name.. '](https://twitter.com/'..quoted_screen_name..')'..quoted_verified..'):\n'..quoted_text - quote = 'Als Antwort auf '..quoted_name..' (@' ..quoted_screen_name..quoted_verified..'):\n'..quoted_text + quote = 'Als Antwort auf '..quoted_name..' (@' ..quoted_screen_name..''..quoted_verified..'):\n'..quoted_text text = text..'\n\n'..quote..'\n' end -- send the parts - local text = unescape(text) - utilities.send_reply(self, msg, header .. "\n" .. text.."\n"..footer) + utilities.send_reply(self, msg, header .. "\n" .. text.."\n"..footer, 'HTML') + if videos[1] then images = {} end for k, v in pairs(images) do local file = download_to_file(v) utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id) @@ -144,4 +142,4 @@ function twitter:action(msg, config, matches) end end -return twitter +return twitter \ No newline at end of file diff --git a/miku/plugins/urbandictionary.lua b/miku/plugins/urbandictionary.lua index 4c2bdee..821fc24 100644 --- a/miku/plugins/urbandictionary.lua +++ b/miku/plugins/urbandictionary.lua @@ -38,15 +38,15 @@ function urbandictionary:action(msg, config) return end - local output = '*' .. jdat.list[1].word .. '*\n' .. utilities.trim(jdat.list[1].definition) + local output = '' .. jdat.list[1].word .. '\n' .. utilities.trim(jdat.list[1].definition) if string.len(jdat.list[1].example) > 0 then - output = output .. '_\n' .. utilities.trim(jdat.list[1].example) .. '_' + output = output .. '\n' .. utilities.trim(jdat.list[1].example) .. '' end - + output = output:gsub('%[', ''):gsub('%]', '') - utilities.send_reply(self, msg, output, true) + utilities.send_reply(self, msg, output, 'HTML') end -return urbandictionary +return urbandictionary \ No newline at end of file diff --git a/miku/plugins/youtube.lua b/miku/plugins/youtube.lua index 3122e8e..4e38169 100644 --- a/miku/plugins/youtube.lua +++ b/miku/plugins/youtube.lua @@ -2,8 +2,8 @@ local youtube = {} function youtube:init(config) if not cred_data.google_apikey then - print('Fehlender Key: google_apikey.') - print('youtube.lua wird nicht aktiviert.') + print('Missing config value: google_apikey.') + print('youtube.lua will not be enabled.') return end @@ -28,13 +28,6 @@ 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)))' @@ -99,7 +92,7 @@ function get_yt_thumbnail(data) end function send_youtube_data(data, msg, self, link, sendpic) - local title = markdown_escape_simple(data.snippet.localized.title) + local title = data.snippet.localized.title -- local description = data.snippet.localized.description local uploader = data.snippet.channelTitle local upload_date = makeOurDate(data.snippet.publishedAt) @@ -127,13 +120,13 @@ function send_youtube_data(data, msg, self, link, sendpic) blocked = false end - text = '*'..title..'*\n_('..uploader..' am '..upload_date..', '..viewCount..'x angesehen, Länge: '..duration..likeCount..dislikeCount..commentCount..')_\n' + text = ''..title..'\n('..uploader..' am '..upload_date..', '..viewCount..'x angesehen, Länge: '..duration..likeCount..dislikeCount..commentCount..')\n' if link then text = link..'\n'..text end if blocked then - text = text..'\n*ACHTUNG, Video ist in Deutschland gesperrt!*' + text = text..'\nACHTUNG, Video ist in Deutschland gesperrt!' end if sendpic then @@ -146,7 +139,7 @@ function send_youtube_data(data, msg, self, link, sendpic) local file = download_to_file(image_url) utilities.send_photo(self, msg.chat.id, file, text, msg.message_id) else - utilities.send_reply(self, msg, text, true) + utilities.send_reply(self, msg, text, 'HTML') end end diff --git a/miku/utilities.lua b/miku/utilities.lua index 33a56cb..1ea93d3 100644 --- a/miku/utilities.lua +++ b/miku/utilities.lua @@ -23,35 +23,50 @@ https.timeout = 5 -- For the sake of ease to new contributors and familiarity to old contributors, -- we'll provide a couple of aliases to real bindings here. function utilities:send_message(chat_id, text, disable_web_page_preview, reply_to_message_id, use_markdown, reply_markup) + if use_markdown == true then + use_markdown = 'Markdown' + elseif not use_markdown then + use_markdown = nil + end return bindings.request(self, 'sendMessage', { chat_id = chat_id, text = text, disable_web_page_preview = disable_web_page_preview, reply_to_message_id = reply_to_message_id, - parse_mode = use_markdown and 'Markdown' or nil, + parse_mode = use_markdown, reply_markup = reply_markup } ) end -- https://core.telegram.org/bots/api#editmessagetext function utilities:edit_message(chat_id, message_id, text, disable_web_page_preview, use_markdown, reply_markup) + if use_markdown == true then + use_markdown = 'Markdown' + elseif not use_markdown then + use_markdown = nil + end return bindings.request(self, 'editMessageText', { chat_id = chat_id, message_id = message_id, text = text, disable_web_page_preview = disable_web_page_preview, - parse_mode = use_markdown and 'Markdown' or nil, + parse_mode = use_markdown, reply_markup = reply_markup } ) end function utilities:send_reply(old_msg, text, use_markdown, reply_markup) + if use_markdown == true then + use_markdown = 'Markdown' + elseif not use_markdown then + use_markdown = nil + end return bindings.request(self, 'sendMessage', { chat_id = old_msg.chat.id, text = text, disable_web_page_preview = true, reply_to_message_id = old_msg.message_id, - parse_mode = use_markdown and 'Markdown' or nil, + parse_mode = use_markdown, reply_markup = reply_markup } ) end @@ -1005,6 +1020,7 @@ function unescape(str) -- Character encoding str = string.gsub(str, "´", "´") str = string.gsub(str, "•", "•") + str = string.gsub(str, "é", "é") str = string.gsub(str, ">", ">") str = string.gsub(str, "…", "…") str = string.gsub(str, "<", "<") @@ -1051,6 +1067,10 @@ function unescape(str) str = string.gsub(str, "Ü", "Ü") str = string.gsub(str, "ü", "ü") str = string.gsub(str, "Ü", "Ü") + + --emoticons + str = string.gsub(str, "⭐️", "⭐️") + --str = string.gsub( str, '(%d+);', function(n) return string.char(n) end ) --str = string.gsub( str, '(%d+);', function(n) return string.char(tonumber(n,16)) end ) str = string.gsub( str, '&', '&' ) -- Be sure to do this after all others') + output = output:gsub('%\n%\n', '