Fixed some bugs

This commit is contained in:
yago 2014-11-17 21:55:25 +01:00
parent f0058d81ce
commit 729d03c7b6
5 changed files with 21 additions and 26 deletions

View File

@ -33,9 +33,9 @@
if msg.text == nil then if msg.text == nil then
return false return false
end end
if msg.from.id == our_id then --if msg.from.id == our_id then
return true -- return false
end --end
if msg.out then if msg.out then
return false return false
end end
@ -66,6 +66,7 @@
print(" should return", result) print(" should return", result)
if (result) then if (result) then
send_msg(receiver, result, ok_cb, false) send_msg(receiver, result, ok_cb, false)
return
end end
end end
end end
@ -81,22 +82,6 @@
-- return -- return
-- end -- 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 -- if string.starts(msg.text, '!cpu') then
-- text = run_bash('uname -snr') .. ' ' .. run_bash('whoami') -- text = run_bash('uname -snr') .. ' ' .. run_bash('whoami')

View File

@ -15,13 +15,19 @@ function getEURUSD(usd)
end end
function run(msg, matches) function run(msg, matches)
if matches[1] == "!eur" then
return getEURUSD(nil)
end
return getEURUSD(matches[1]) return getEURUSD(matches[1])
end end
return { return {
description = "EURUSD market value", description = "EURUSD market value",
usage = "!eur [USD]", usage = "!eur [USD]",
patterns = {"^!eur (%d+[%d%.]*)$"}, patterns = {
"^!eur$",
"^!eur (%d+[%d%.]*)$",
},
run = run run = run
} }

View File

@ -15,13 +15,17 @@ function get_value( value_name )
end end
function run(msg, matches) function run(msg, matches)
local text = matches[1] if matches[1] == "!get" then
return text return get_value(nil)
end
return get_value(matches[1])
end end
return { return {
description = "retrieves variables saved with !set", description = "retrieves variables saved with !set",
usage = "!get (value_name)", usage = "!get (value_name)",
patterns = {"^!get ?(%a+)?$"}, patterns = {
"^!get (%a+)$",
"^!get$"},
run = run run = run
} }

View File

@ -1,5 +1,5 @@
function save_value( text ) 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 if (var_name == nil or var_value == nil) then
return "Usage: !set var_name value" return "Usage: !set var_name value"
end end

View File

@ -29,6 +29,6 @@ end
return { return {
description = "Sends a tweet", description = "Sends a tweet",
usage = "!tw [text]", usage = "!tw [text]",
patterns = {"!tw (.+)"}, patterns = {"^!tw (.+)"},
run = run run = run
} }