equal
deleted
inserted
replaced
7 end |
7 end |
8 function rtrim(s) |
8 function rtrim(s) |
9 return s:gsub("%s+$", "") |
9 return s:gsub("%s+$", "") |
10 end |
10 end |
11 |
11 |
12 function string.starts(String,Start) |
12 function string.starts(String, Start) |
13 return string.sub(String, 1, string.len(Start)) == Start |
13 return string.sub(String, 1, string.len(Start)) == Start |
14 end |
14 end |
15 |
15 |
16 function mcbot_register_command (name, object) |
16 function mcbot_register_command (name, object) |
17 commands[name] = object |
17 commands[name] = object |
30 require "cmds.xep" |
30 require "cmds.xep" |
31 require "cmds.mcabber_bts" |
31 require "cmds.mcabber_bts" |
32 require "cmds.bofh" |
32 require "cmds.bofh" |
33 require "cmds.xmpp" |
33 require "cmds.xmpp" |
34 |
34 |
35 function process (line, botdata, muc) |
35 function process (line, botdata, muc, cmdprefix) |
36 local n |
36 local n |
37 line = trim(line) |
37 line = trim(line) |
38 line, n = line:gsub("^"..botdata.nickname.."[,:]?%s+", "") |
38 line, n = line:gsub("^"..botdata.nickname.."[,:]?%s+", "") |
39 if muc and n ~= 1 then return nil, nil end |
39 if muc and n ~= 1 then |
|
40 if cmdprefix and line:starts(cmdprefix) then |
|
41 line = line:sub(string.len(cmdprefix)+1) |
|
42 line = line:gsub("^%s*", "") |
|
43 else |
|
44 return nil, nil |
|
45 end |
|
46 end |
40 |
47 |
41 local cmd, arg |
48 local cmd, arg |
42 cmd = line:match("^(%w+)%s*[!]*$") |
49 cmd = line:match("^(%w+)%s*[!]*$") |
43 if not cmd then |
50 if not cmd then |
44 -- Check if there are arguments |
51 -- Check if there are arguments |