-
Notifications
You must be signed in to change notification settings - Fork 16
/
luatest.lua
116 lines (95 loc) · 3.73 KB
/
luatest.lua
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
local luatest = {}
local function cmd_lua(msg)
if msg then
prof_cons_show("luatest: /lua command called, arg = " .. msg)
else
prof_cons_show("luatest: /lua command called with no arg")
end
prof_cons_alert()
prof_notify("luatest: notify", 8000, "Plugins")
prof_send_line("/account list")
prof_cons_show("luatest: sent \"/account list\" command")
end
local function timer_test()
prof_cons_show("luatest: timer fired.")
recipient = prof_get_current_recipient()
if recipient then
prof_cons_show(" current recipient = " .. recipient)
end
prof_cons_alert()
end
local function handle_bracket(win, line)
prof_win_show(win, "(" .. line .. ")")
prof_win_show_red(win, "Red")
prof_win_show_yellow(win, "Yellow")
prof_win_show_green(win, "Green")
prof_win_show_cyan(win, "Cyan")
end
local function cmd_bracket(line)
win_tag = "Parenthesise echo";
if prof_win_exists(win_tag) == false then
prof_win_create(win_tag, handle_bracket);
end
prof_win_focus(win_tag);
if line then
handle_bracket(win_tag, line)
end
end
function luatest.prof_init(version, status)
prof_cons_show("luatest: init, " .. version .. ", " .. status)
prof_register_command("/lua", 0, 1, "/lua", "luatest", "luatest", cmd_lua)
prof_register_command("/bracket", 0, 1, "/bracket", "Parenthesise input string", "Parenthesise input string", cmd_bracket);
prof_register_ac("/lcomplete", { "football", "footy", "tennis" })
prof_register_ac("/lcomplete football", { "goal", "out", "try", "given" })
prof_register_ac("/lcomplete tennis", { "test", "prod", "dev", "stage" })
prof_register_command("/lcomplete", 0, 2, "/lcomplete", "Lua completion", "Lua completion", cmd_bracket)
prof_register_timed(timer_test, 10)
end
function luatest.prof_on_start()
prof_cons_show("luatest: on_start")
prof_log_debug("luatest: logged debug");
prof_log_info("luatest: logged info");
prof_log_warning("luatest: logged warning");
prof_log_error("luatest: logged error");
end
function luatest.prof_on_connect(account_name, fulljid)
prof_cons_show("luatest: on_connect, " .. account_name .. ", " .. fulljid)
end
function luatest.prof_on_disconnect(account_name, fulljid)
prof_cons_show("luatest: on_disconnect, " .. account_name .. ", " .. fulljid)
prof_log_info("luatest: on_disconnect, " .. account_name .. ", " .. fulljid)
end
function luatest.prof_on_message_received(jid, message)
prof_cons_show("luatest: on_message_received, " .. jid .. ", " .. message)
prof_cons_alert()
return message .. "[LUA]"
end
function luatest.prof_on_room_message_received(room, nick, message)
prof_cons_show("luatest: on_room_message_received, " .. room .. ", " .. nick .. ", " .. message)
prof_cons_alert()
return message .. "[LUA]"
end
function luatest.prof_on_private_message_received(room, nick, message)
prof_cons_show("luatest: on_private_message_received, " .. room .. ", " .. nick .. ", " .. message)
prof_cons_alert()
return message .. "[LUA]"
end
function luatest.prof_on_message_send(jid, message)
prof_cons_show("luatest: on_message_send, " .. jid .. ", " .. message)
prof_cons_alert()
return message .. "[LUA]"
end
function luatest.prof_on_private_message_send(room, nick, message)
prof_cons_show("luatest: on_private_message_send, " .. room .. ", " .. nick .. ", " .. message)
prof_cons_alert()
return message .. "[LUA]"
end
function luatest.prof_on_room_message_send(room, message)
prof_cons_show("luatest: on_room_message_send, " .. room .. ", " .. message)
prof_cons_alert()
return message .. "[LUA]"
end
function luatest.prof_on_shutdown()
prof_log_info("luatest: on_shutdown")
end
return luatest