From 88a506492b33045db8494f598c6d7cbc7a7e2665 Mon Sep 17 00:00:00 2001 From: topkecleon Date: Mon, 14 Dec 2015 14:48:17 -0500 Subject: [PATCH] some improvements --- .gitignore | 1 + config.lua | 2 ++ plugins/hackernews.lua | 2 ++ plugins/luarun.lua | 8 ++++++-- plugins/shell.lua | 8 ++++++-- plugins/shout.lua | 5 +++++ 6 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..275c49b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +plugins/administration.lua diff --git a/config.lua b/config.lua index 33f4ff8..d8c7574 100755 --- a/config.lua +++ b/config.lua @@ -9,6 +9,7 @@ return { time_offset = 0, lang = 'en', admin = 00000000, + admin_name = 'John Smith', about_text = [[ I am otouto, the plugin-wielding, multi-purpose Telegram bot written by topkecleon. @@ -93,6 +94,7 @@ telegram.me/otouto 'bandersnatch.lua', 'currency.lua', 'cats.lua', + 'shout.lua', -- Put new plugins here. 'help.lua', 'greetings.lua' diff --git a/plugins/hackernews.lua b/plugins/hackernews.lua index da43f4f..97654d6 100755 --- a/plugins/hackernews.lua +++ b/plugins/hackernews.lua @@ -10,6 +10,8 @@ local triggers = { local action = function(msg) + sendChatAction(msg.chat.id, 'typing') + local jstr, res = HTTPS.request('https://hacker-news.firebaseio.com/v0/topstories.json') if res ~= 200 then sendReply(msg, config.errors.connection) diff --git a/plugins/luarun.lua b/plugins/luarun.lua index 0c71ee0..cf7d246 100644 --- a/plugins/luarun.lua +++ b/plugins/luarun.lua @@ -15,8 +15,12 @@ local action = function(msg) end local output = loadstring(input)() - if not output then output = 'Done!' end - sendReply(msg, output) + if not output then + output = 'Done!' + else + output = '```\n' .. output .. '\n```' + end + sendMessage(msg.chat.id, output, true, msg.message_id, true) end diff --git a/plugins/shell.lua b/plugins/shell.lua index 38fc392..411f09b 100644 --- a/plugins/shell.lua +++ b/plugins/shell.lua @@ -15,8 +15,12 @@ local action = function(msg) end local output = io.popen(input):read('*all') - if output:len() == 0 then output = 'Done!' end - sendReply(msg, output) + if output:len() == 0 then + output = 'Done!' + else + output = '```\n' .. output .. '\n```' + end + sendMessage(msg.chat.id, output, true, msg.message_id, true) end diff --git a/plugins/shout.lua b/plugins/shout.lua index 8967de5..60bb8b8 100644 --- a/plugins/shout.lua +++ b/plugins/shout.lua @@ -15,6 +15,11 @@ local action = function(msg) sendReply(msg, doc) return end + input = input:trim() + + if input:len() > 20 then + input = input:sub(1,20) + end input = input:upper() local output = ''