markdown support in messages
other changes & improvements
This commit is contained in:
parent
c5c3660de4
commit
80f363de44
@ -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]
|
||||
|
@ -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
|
||||
|
2
bot.lua
2
bot.lua
@ -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
|
||||
|
@ -65,6 +65,7 @@ telegram.me/otouto
|
||||
'floodcontrol.lua',
|
||||
'admin.lua',
|
||||
'about.lua',
|
||||
'ping.lua',
|
||||
'whoami.lua',
|
||||
'nick.lua',
|
||||
'echo.lua',
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
14
plugins/ping.lua
Normal 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
|
||||
}
|
Reference in New Issue
Block a user