aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/factoids/sandbox.lua
blob: 8ebf51851fb2ccd27b0fabc8c0fb0a79d6674f8c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function send(text)
  local text = tostring(text)
  local len = #output
  if len < 1 then
    output = { text }
  else
    output[len] = output[len] .. text
  end
end

function sendln(text)
  send(text)
  table.insert(output, "")
end

local env = { print = send,
              println = sendln,
              args = args,
              input = input,
              user = user,
              channel = channel,
              request = download,
              pairs = pairs,
              table = table,
              string = string,
              tostring = tostring,
              math = math }

local f, e = load(factoid, nil, nil, env)
if f then
  f()
else
  error(e)
end