From 729d03c7b6f7751ae9a68918002dedfd629a9fd6 Mon Sep 17 00:00:00 2001 From: yago Date: Mon, 17 Nov 2014 21:55:25 +0100 Subject: [PATCH] Fixed some bugs --- bot/bot.lua | 23 ++++------------------- plugins/eur.lua | 10 ++++++++-- plugins/get.lua | 10 +++++++--- plugins/set.lua | 2 +- plugins/twitter_send.lua | 2 +- 5 files changed, 21 insertions(+), 26 deletions(-) diff --git a/bot/bot.lua b/bot/bot.lua index 8a21063..ab28153 100644 --- a/bot/bot.lua +++ b/bot/bot.lua @@ -33,9 +33,9 @@ if msg.text == nil then return false end - if msg.from.id == our_id then - return true - end + --if msg.from.id == our_id then + -- return false + --end if msg.out then return false end @@ -66,6 +66,7 @@ print(" should return", result) if (result) then send_msg(receiver, result, ok_cb, false) + return end end end @@ -81,22 +82,6 @@ -- return -- end -- - -- if string.starts(msg.text, '!fortune') then - -- text = run_bash('fortune') - -- send_msg(receiver, text, ok_cb, false) - -- return - -- end - - -- if string.starts(msg.text, '!forni') then - -- text = msg.text:sub(8,-1) - -- send_msg('Fornicio_2.0', text, ok_cb, false) - -- return - -- end - - -- if string.starts(msg.text, '!fwd') then - -- fwd_msg (receiver, msg.id, ok_cb, false) - -- return - -- end -- if string.starts(msg.text, '!cpu') then -- text = run_bash('uname -snr') .. ' ' .. run_bash('whoami') diff --git a/plugins/eur.lua b/plugins/eur.lua index 1fa3629..39ded90 100644 --- a/plugins/eur.lua +++ b/plugins/eur.lua @@ -15,13 +15,19 @@ function getEURUSD(usd) end function run(msg, matches) - return getEURUSD(matches[1]) + if matches[1] == "!eur" then + return getEURUSD(nil) + end + return getEURUSD(matches[1]) end return { description = "EURUSD market value", usage = "!eur [USD]", - patterns = {"^!eur (%d+[%d%.]*)$"}, + patterns = { + "^!eur$", + "^!eur (%d+[%d%.]*)$", + }, run = run } diff --git a/plugins/get.lua b/plugins/get.lua index 397992f..52a2dd4 100644 --- a/plugins/get.lua +++ b/plugins/get.lua @@ -15,13 +15,17 @@ function get_value( value_name ) end function run(msg, matches) - local text = matches[1] - return text + if matches[1] == "!get" then + return get_value(nil) + end + return get_value(matches[1]) end return { description = "retrieves variables saved with !set", usage = "!get (value_name)", - patterns = {"^!get ?(%a+)?$"}, + patterns = { + "^!get (%a+)$", + "^!get$"}, run = run } diff --git a/plugins/set.lua b/plugins/set.lua index c0c1420..da0dedd 100644 --- a/plugins/set.lua +++ b/plugins/set.lua @@ -1,5 +1,5 @@ function save_value( text ) - var_name, var_value = string.match(text, "(%a+) (.+)") + var_name, var_value = string.match(text, "!set (%a+) (.+)") if (var_name == nil or var_value == nil) then return "Usage: !set var_name value" end diff --git a/plugins/twitter_send.lua b/plugins/twitter_send.lua index 67454af..952a8b1 100644 --- a/plugins/twitter_send.lua +++ b/plugins/twitter_send.lua @@ -29,6 +29,6 @@ end return { description = "Sends a tweet", usage = "!tw [text]", - patterns = {"!tw (.+)"}, + patterns = {"^!tw (.+)"}, run = run } \ No newline at end of file