markdown support in messages

other changes & improvements
This commit is contained in:
topkecleon 2015-12-05 09:30:52 -05:00
parent c5c3660de4
commit 80f363de44
8 changed files with 32 additions and 5 deletions

View File

@ -21,6 +21,12 @@ Below are listed many (but not all) of otouto's plugins. This list will be updat
>**Notes:** Replaces letters with corresponding characters from the Cyrillic alphabet.
###**ping.lua**
>**Command:** /ping
>**Function:** The simplest plugin ever!
###**gSearch.lua**
>**Command:** /google [query]

View File

@ -40,7 +40,7 @@ getUpdates = function(offset)
end
sendMessage = function(chat_id, text, disable_web_page_preview, reply_to_message_id)
sendMessage = function(chat_id, text, disable_web_page_preview, reply_to_message_id, use_markdown)
local url = BASE_URL .. '/sendMessage?chat_id=' .. chat_id .. '&text=' .. URL.escape(text)
@ -52,6 +52,10 @@ sendMessage = function(chat_id, text, disable_web_page_preview, reply_to_message
url = url .. '&reply_to_message_id=' .. reply_to_message_id
end
if use_markdown then
url = url .. '&parse_mode=Markdown'
end
return sendRequest(url)
end

View File

@ -74,7 +74,7 @@ while is_started do -- Start a loop while the bot should be running.
local res = getUpdates(last_update+1) -- Get the latest updates!
if res then
for i,v in ipairs(res.result) do -- Go through every new damned message.
for i,v in ipairs(res.result) do -- Go through every new message.
last_update = v.update_id
on_msg_receive(v.message)
end

View File

@ -65,6 +65,7 @@ telegram.me/otouto
'floodcontrol.lua',
'admin.lua',
'about.lua',
'ping.lua',
'whoami.lua',
'nick.lua',
'echo.lua',

View File

@ -13,6 +13,8 @@ local action = function(msg)
-- This is awkward, but if you have a better way, please share.
if msg.text_lower:match('^' .. bot.first_name .. ',') then
elseif msg.text_lower:match('^@' .. bot.username .. ',') then
elseif msg.text:match('^/') then
return true
-- Uncomment the following line for Al Gore-like reply chatter.
-- elseif msg.reply_to_message and msg.reply_to_message.from.id == bot.id then
elseif msg.from.id == msg.chat.id then

View File

@ -1,7 +1,7 @@
-- Requires that the "fortune" program is installed on your computer.
local s = io.popen('fortune'):read('*all')
if s:match('fortune: command not found') then
local s = io.popen('fortune'):read('*all')
if s:match('fortune: command not found') then
print('fortune is not installed on this computer.')
print('fortune.lua will not be enabled.')
return

View File

@ -90,7 +90,7 @@ local action = function(msg)
end
message = message .. title .. ' - ' .. artist
sendReply(msg, message)
sendMessage(msg.chat.id, message)
end

14
plugins/ping.lua Normal file
View File

@ -0,0 +1,14 @@
-- Actually the simplest plugin ever!
local triggers = {
'^/ping[@'..bot.username..']*'
}
local action = function(msg)
sendMessage(msg.chat.id, 'Pong!')
end
return {
action = action,
triggers = triggers
}