author | Myhailo Danylenko <isbear@ukrpost.net> |
Fri, 05 Mar 2010 19:15:08 +0200 | |
changeset 92 | 5d691423c8a6 |
parent 84 | c0db7efde255 |
child 99 | ed4676536ed9 |
permissions | -rw-r--r-- |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
1 |
|
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
2 |
|
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
3 |
--[[ |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
4 |
|
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
5 |
DESCRIPTION |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
6 |
|
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
7 |
This is a demo config file to show, what you can do with lua. |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
8 |
|
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
9 |
Feature list: |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
10 |
XEP-0004 Forms parsing and filling |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
11 |
XEP-0030 Info/items discovery requests (mcabber already can do replies) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
12 |
XEP-0047 In-Bound Byte Streams (sending, receiving, saving with specified name, rejecting) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
13 |
XEP-0077 In-Band Registration (only registration, but with data forms too) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
14 |
XEP-0146 Remote commands requests |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
15 |
Jobs (actions, fired when some event occurs, now in one file, updated on exit) |
8 | 16 |
Room nicks completion |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
17 |
MPD status polling (can be turned off) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
18 |
Beep on all messages, even on chatroom ones |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
19 |
Url saving to file (for urlview) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
20 |
Transported buddies availability indication |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
21 |
Actions on multiple marked buddies |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
22 |
Fallback commands (localized also! :) ) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
23 |
Help for fallback commands (well, I know, that it can be done with mcabber's help system, but it requires access to system files...) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
24 |
All features have native mcabber interface |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
25 |
|
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
26 |
REQUIREMENTS |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
27 |
|
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
28 |
liblua-loudmouth (lm.lua and loudmouth.so) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
29 |
liblua-socket - mpd |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
30 |
|
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
31 |
NOTES |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
32 |
|
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
33 |
Ibb uses own iq handler. This is the laziest way to implement this. |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
34 |
|
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
35 |
BUILTINS |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
36 |
|
9 | 37 |
print (global) - prints to log/status/logwindow |
38 |
dofile (global) - loads lua file from default mcabber location |
|
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
39 |
|
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
40 |
main methods: |
9 | 41 |
- run - run literal mcabber command |
42 |
- beep - beep |
|
43 |
- log - print to log w/specified priority |
|
44 |
- print_info - print info into specified buffer |
|
45 |
- config_file - format full file name from relative to mcabber's config dir |
|
46 |
- status - get current user status and message |
|
47 |
- roster - get list of roster jids (rooms, buddies and agents) |
|
48 |
- current_buddy - get jid of current buddy |
|
49 |
- buddy_info - get table with info about jid and its resources |
|
50 |
- connection - get lightuserdata for mcabber's lm connection |
|
51 |
- timer - run function periodically |
|
52 |
- bgread - run command and read it's output in background |
|
53 |
- add_feature - add string to feature list (for disco#info) |
|
54 |
- del_feature - delete string from feature list |
|
55 |
- add_completion - adds word to completions |
|
56 |
- del_completion - removes word from completions |
|
57 |
- command - adds/removes mcabber command |
|
58 |
- option - sets/gets mcabber option |
|
59 |
||
60 |
STRUCTURE |
|
61 |
||
62 |
To allow your chunk of configuration (eg foo.lua) to play friendly with other, do: |
|
63 |
||
64 |
- place it into a separate file, eg foo.lua |
|
65 |
- if you need hooks, do |
|
66 |
hook_d[hookname].foo = function ( args ) foo ( ) end |
|
67 |
- if you register commands, also do |
|
68 |
commands_help['foo'] = "arg1 arg2\n\nFoo does bar." |
|
69 |
- append to the end of this file |
|
70 |
dopath 'foo' |
|
71 |
- try to be friendly to module reloads, eg unregister handlers, where appropriate, |
|
72 |
reset bindings |
|
73 |
- you can omit unregistering of commands and xmpp features - module will unregister |
|
74 |
them automatically. |
|
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
75 |
|
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
76 |
--]] |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
77 |
|
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
78 |
-- This is a hack to allow loading of lm.lua and loudmouth.so from ~/.mcabber |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
79 |
-- instead of installing them system-wide |
57 | 80 |
-- FIXME to C. we now require this by require'ing interdependencies between modules. |
31
54957980a83a
yesno in C, no config_file
Myhailo Danylenko <isbear@ukrpost.net>
parents:
27
diff
changeset
|
81 |
if main.option ( 'lua_extra_include' ) then |
33 | 82 |
package.path = main.fileoption ( 'lua_extra_include' ) .. '/?.lua;' .. package.path |
83 |
package.cpath = main.fileoption ( 'lua_extra_include' ) .. '/?.so;' .. package.cpath |
|
31
54957980a83a
yesno in C, no config_file
Myhailo Danylenko <isbear@ukrpost.net>
parents:
27
diff
changeset
|
84 |
end |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
85 |
|
8 | 86 |
-- COMMON SUPPORT ROUTINES |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
87 |
|
32
524fde5be49a
Yesno completion in C
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
88 |
-- unused :/ |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
89 |
function shell_escape ( str ) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
90 |
if str then |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
91 |
return "'" .. str:gsub ( "'", "'\\''" ) .. "'" |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
92 |
else |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
93 |
return "''" |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
94 |
end |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
95 |
end |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
96 |
|
31
54957980a83a
yesno in C, no config_file
Myhailo Danylenko <isbear@ukrpost.net>
parents:
27
diff
changeset
|
97 |
-- This is for debugging purposes, not for reloading. For that see jobs. |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
98 |
function table_to_string ( tab, pre ) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
99 |
local prefix = pre or "" |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
100 |
local tbls, jk = "", "" |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
101 |
|
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
102 |
for key, val in pairs ( tab ) do |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
103 |
if type ( val ) == 'table' then |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
104 |
tbls = string.format ( "%s %s%s = %s,\n", tbls, prefix, tostring(key), table_to_string ( val, " " .. prefix ) ) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
105 |
else |
31
54957980a83a
yesno in C, no config_file
Myhailo Danylenko <isbear@ukrpost.net>
parents:
27
diff
changeset
|
106 |
jk = string.format ( "%s %s = \"%s\",", jk, tostring(key), tostring(val) ) |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
107 |
end |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
108 |
end |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
109 |
|
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
110 |
if tbls == "" then |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
111 |
return string.format ( "{%s }", jk:sub ( 1, -2 ) ) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
112 |
else |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
113 |
return string.format ( "{%s\n%s%s}", jk, tbls, prefix ) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
114 |
end |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
115 |
end |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
116 |
|
6 | 117 |
-- COMMANDS |
118 |
||
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
119 |
-- Help strings should not contain command, only arguments. This is necessary to support soft aliases. |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
120 |
commands_help = { |
7
eb6d89bf1fbf
Commands and init improvements
Myhailo Danylenko <isbear@ukrpost.net>
parents:
6
diff
changeset
|
121 |
post = "filename\n\nSends file as a message. Just shorthand.", |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
122 |
beep = "[enable|disable|on|off|yes|no|true|false]\n\nEnables or disables beeping on all messages.\nIf state is omitted, prints current state.", |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
123 |
cmd = "shell_command\n\nRuns shell command in background and sends output to current buddy.\nWorks asynchroneously, and may break long output in the middle of line", |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
124 |
exthelp = "[command]\n\nPrints help for a given command, or list of available help topics.", |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
125 |
['join!'] = "\n\nForcibly joins to current buddy. Just saves you typing of full room name (that can be quite long) in a case of a non-bookmarked rooms.", |
12
a52d61f57e0d
Toggle status function
Myhailo Danylenko <isbear@ukrpost.net>
parents:
10
diff
changeset
|
126 |
count = "\n\nPrints number of resources of current buddy. Useful to determine member count of large room.", |
a52d61f57e0d
Toggle status function
Myhailo Danylenko <isbear@ukrpost.net>
parents:
10
diff
changeset
|
127 |
toggle = "\n\nToggles away/online status.", |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
128 |
} |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
129 |
|
7
eb6d89bf1fbf
Commands and init improvements
Myhailo Danylenko <isbear@ukrpost.net>
parents:
6
diff
changeset
|
130 |
main.command ( 'post', |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
131 |
function ( args ) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
132 |
main.run ( 'say_to -f ' .. args .. ' .' ) |
34
8206d7cb1447
Args auto-parsing, use main.binding
Myhailo Danylenko <isbear@ukrpost.net>
parents:
33
diff
changeset
|
133 |
end, false, 'filename' ) |
7
eb6d89bf1fbf
Commands and init improvements
Myhailo Danylenko <isbear@ukrpost.net>
parents:
6
diff
changeset
|
134 |
main.command ( 'cmd', |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
135 |
function ( args ) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
136 |
local to = main.current_buddy () |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
137 |
main.run ( ('send_to -q %q $ %s'):format ( to, args ) ) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
138 |
main.bgread ( args, |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
139 |
function ( data ) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
140 |
if data then |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
141 |
main.run ( ('send_to -q %q %s'):format ( to, data ) ) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
142 |
return true |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
143 |
else |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
144 |
return false |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
145 |
end |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
146 |
end ) |
34
8206d7cb1447
Args auto-parsing, use main.binding
Myhailo Danylenko <isbear@ukrpost.net>
parents:
33
diff
changeset
|
147 |
end, false, 'filename' ) |
7
eb6d89bf1fbf
Commands and init improvements
Myhailo Danylenko <isbear@ukrpost.net>
parents:
6
diff
changeset
|
148 |
main.command ( 'exthelp', |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
149 |
function ( args ) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
150 |
if commands_help[args] then |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
151 |
print ( "\n /" .. args .. ' ' .. commands_help[args] ) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
152 |
else |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
153 |
print ( "No help for this command." ) |
41
9e39fd8a20df
Updated to library module ibb
Myhailo Danylenko <isbear@ukrpost.net>
parents:
37
diff
changeset
|
154 |
local list = "Help available for commands: " |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
155 |
for k in pairs (commands_help) do |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
156 |
list = list .. k .. ', ' |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
157 |
end |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
158 |
print ( list:sub ( 1, -3 ) ) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
159 |
print ( "For built-in mcabber commands see /help" ) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
160 |
end |
34
8206d7cb1447
Args auto-parsing, use main.binding
Myhailo Danylenko <isbear@ukrpost.net>
parents:
33
diff
changeset
|
161 |
end, false, 'cmd' ) |
7
eb6d89bf1fbf
Commands and init improvements
Myhailo Danylenko <isbear@ukrpost.net>
parents:
6
diff
changeset
|
162 |
main.command ( 'join!', |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
163 |
function ( args ) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
164 |
main.run ( 'room join ' .. main.current_buddy () ) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
165 |
end ) |
7
eb6d89bf1fbf
Commands and init improvements
Myhailo Danylenko <isbear@ukrpost.net>
parents:
6
diff
changeset
|
166 |
main.command ( 'count', |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
167 |
function ( args ) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
168 |
local count = 0 |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
169 |
for resource in pairs ( main.buddy_info ( main.current_buddy () ).resources ) do |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
170 |
count = count + 1 |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
171 |
end |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
172 |
print ( "Resource count: " .. count ) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
173 |
end ) |
12
a52d61f57e0d
Toggle status function
Myhailo Danylenko <isbear@ukrpost.net>
parents:
10
diff
changeset
|
174 |
main.command ( 'toggle', |
a52d61f57e0d
Toggle status function
Myhailo Danylenko <isbear@ukrpost.net>
parents:
10
diff
changeset
|
175 |
function ( args ) |
a52d61f57e0d
Toggle status function
Myhailo Danylenko <isbear@ukrpost.net>
parents:
10
diff
changeset
|
176 |
local stat, mess = main.status () |
a52d61f57e0d
Toggle status function
Myhailo Danylenko <isbear@ukrpost.net>
parents:
10
diff
changeset
|
177 |
if stat == 'o' then |
a52d61f57e0d
Toggle status function
Myhailo Danylenko <isbear@ukrpost.net>
parents:
10
diff
changeset
|
178 |
main.run ( 'status away ' .. mess ) |
a52d61f57e0d
Toggle status function
Myhailo Danylenko <isbear@ukrpost.net>
parents:
10
diff
changeset
|
179 |
else |
a52d61f57e0d
Toggle status function
Myhailo Danylenko <isbear@ukrpost.net>
parents:
10
diff
changeset
|
180 |
main.run ( 'status online ' .. mess ) |
a52d61f57e0d
Toggle status function
Myhailo Danylenko <isbear@ukrpost.net>
parents:
10
diff
changeset
|
181 |
end |
a52d61f57e0d
Toggle status function
Myhailo Danylenko <isbear@ukrpost.net>
parents:
10
diff
changeset
|
182 |
end ) |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
183 |
|
8 | 184 |
-- commands to allow leading smileys |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
185 |
for k, arg in ipairs ( { ')', '/', '(', 'D', '-/', 'S', '1', ']', '[' } ) do |
7
eb6d89bf1fbf
Commands and init improvements
Myhailo Danylenko <isbear@ukrpost.net>
parents:
6
diff
changeset
|
186 |
main.command ( arg, |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
187 |
function ( args ) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
188 |
main.run ( 'say :' .. arg .. ' ' .. args ) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
189 |
end ) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
190 |
end |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
191 |
|
8 | 192 |
-- HOOKS |
193 |
||
194 |
hooks_d = { |
|
195 |
['hook-message-in'] = { }, |
|
196 |
['hook-message-out'] = { }, |
|
197 |
['hook-status-change'] = { }, |
|
198 |
['hook-my-status-change'] = { }, |
|
199 |
['hook-post-connect'] = { }, |
|
200 |
['hook-pre-disconnect'] = { }, |
|
201 |
['hook-start'] = { }, |
|
202 |
['hook-quit'] = { }, |
|
203 |
} |
|
204 |
||
205 |
-- hook: |
|
206 |
-- - hook-message-in |
|
207 |
-- jid |
|
208 |
-- groupchat |
|
209 |
-- message |
|
210 |
-- - hook-message-out |
|
211 |
-- jid |
|
212 |
-- message |
|
213 |
-- - hook-status-change |
|
214 |
-- jid |
|
215 |
-- resource |
|
216 |
-- new_status |
|
217 |
-- old_status |
|
218 |
-- message |
|
219 |
-- - hook-my-status-change |
|
220 |
-- new_status |
|
221 |
-- message |
|
222 |
-- - hook-post-connect |
|
223 |
-- - hook-pre-disconnect |
|
224 |
-- - hook-start |
|
225 |
-- - hook-quit |
|
226 |
function hook_handler ( args ) |
|
84 | 227 |
if [hooks_d[args.hook] then |
228 |
for mod, cb in pairs ( hooks_d[args.hook] ) do |
|
229 |
if cb then |
|
230 |
cb ( args ) |
|
231 |
end |
|
8 | 232 |
end |
233 |
end |
|
234 |
end |
|
235 |
||
71
eb6edac301ac
Fixes to tune and register, change fifo perm
Myhailo Danylenko <isbear@ukrpost.net>
parents:
68
diff
changeset
|
236 |
-- FIXME |
eb6edac301ac
Fixes to tune and register, change fifo perm
Myhailo Danylenko <isbear@ukrpost.net>
parents:
68
diff
changeset
|
237 |
|
eb6edac301ac
Fixes to tune and register, change fifo perm
Myhailo Danylenko <isbear@ukrpost.net>
parents:
68
diff
changeset
|
238 |
hooks_d['hook-post-connect'].fifoperms = |
eb6edac301ac
Fixes to tune and register, change fifo perm
Myhailo Danylenko <isbear@ukrpost.net>
parents:
68
diff
changeset
|
239 |
function ( args ) |
eb6edac301ac
Fixes to tune and register, change fifo perm
Myhailo Danylenko <isbear@ukrpost.net>
parents:
68
diff
changeset
|
240 |
-- TODO: posix |
eb6edac301ac
Fixes to tune and register, change fifo perm
Myhailo Danylenko <isbear@ukrpost.net>
parents:
68
diff
changeset
|
241 |
os.execute ( 'chmod 0666 ' .. main.option ( 'fifo_name' ) ) |
eb6edac301ac
Fixes to tune and register, change fifo perm
Myhailo Danylenko <isbear@ukrpost.net>
parents:
68
diff
changeset
|
242 |
hooks_d['hook-post-connect'].fifoperms = nil |
eb6edac301ac
Fixes to tune and register, change fifo perm
Myhailo Danylenko <isbear@ukrpost.net>
parents:
68
diff
changeset
|
243 |
end |
eb6edac301ac
Fixes to tune and register, change fifo perm
Myhailo Danylenko <isbear@ukrpost.net>
parents:
68
diff
changeset
|
244 |
|
8 | 245 |
-- SAVING URLS TO FILE |
246 |
||
57 | 247 |
require 'urls' |
8 | 248 |
|
249 |
-- TRANSPORTED BUDDIES AVAILABILITY INDICATION |
|
250 |
||
57 | 251 |
require 'transports' |
8 | 252 |
|
253 |
-- BEEPING ON ALL MESSAGES |
|
254 |
||
57 | 255 |
require 'beep' |
8 | 256 |
|
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
257 |
-- MARKING |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
258 |
|
57 | 259 |
require 'marking' |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
260 |
|
50 | 261 |
-- JOBS |
262 |
||
57 | 263 |
require 'jobs' |
50 | 264 |
|
265 |
-- ROOM NICK COMPLETION |
|
266 |
||
57 | 267 |
require 'room_priv' |
50 | 268 |
|
67
d33ca5572e91
Fully object forms interface (untested)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
66
diff
changeset
|
269 |
-- FORMS |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
270 |
|
68
742878c74b8e
Lm separation, privacy
Myhailo Danylenko <isbear@ukrpost.net>
parents:
67
diff
changeset
|
271 |
require 'forms' |
67
d33ca5572e91
Fully object forms interface (untested)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
66
diff
changeset
|
272 |
|
d33ca5572e91
Fully object forms interface (untested)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
66
diff
changeset
|
273 |
-- DATA FORMS (XEP-0004) |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
274 |
|
68
742878c74b8e
Lm separation, privacy
Myhailo Danylenko <isbear@ukrpost.net>
parents:
67
diff
changeset
|
275 |
-- PRIVACY LISTS (XEP-0016) |
742878c74b8e
Lm separation, privacy
Myhailo Danylenko <isbear@ukrpost.net>
parents:
67
diff
changeset
|
276 |
|
742878c74b8e
Lm separation, privacy
Myhailo Danylenko <isbear@ukrpost.net>
parents:
67
diff
changeset
|
277 |
require 'privacy' |
742878c74b8e
Lm separation, privacy
Myhailo Danylenko <isbear@ukrpost.net>
parents:
67
diff
changeset
|
278 |
|
32
524fde5be49a
Yesno completion in C
Myhailo Danylenko <isbear@ukrpost.net>
parents:
31
diff
changeset
|
279 |
-- SERVICE DISCOVERY (XEP-0030) |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
280 |
|
68
742878c74b8e
Lm separation, privacy
Myhailo Danylenko <isbear@ukrpost.net>
parents:
67
diff
changeset
|
281 |
require 'disco' |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
282 |
|
77
8a7f7829f4df
Muc room configuration by owner
Myhailo Danylenko <isbear@ukrpost.net>
parents:
71
diff
changeset
|
283 |
-- MULTI-USER CHAT (XEP-0045) |
8a7f7829f4df
Muc room configuration by owner
Myhailo Danylenko <isbear@ukrpost.net>
parents:
71
diff
changeset
|
284 |
|
8a7f7829f4df
Muc room configuration by owner
Myhailo Danylenko <isbear@ukrpost.net>
parents:
71
diff
changeset
|
285 |
require 'muc' |
8a7f7829f4df
Muc room configuration by owner
Myhailo Danylenko <isbear@ukrpost.net>
parents:
71
diff
changeset
|
286 |
|
41
9e39fd8a20df
Updated to library module ibb
Myhailo Danylenko <isbear@ukrpost.net>
parents:
37
diff
changeset
|
287 |
-- IN-BAND BYTESTREAMS (XEP-0047) |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
288 |
|
68
742878c74b8e
Lm separation, privacy
Myhailo Danylenko <isbear@ukrpost.net>
parents:
67
diff
changeset
|
289 |
require 'ibb' |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
290 |
|
62 | 291 |
-- VCARD-TEMP (XEP-0054) |
292 |
||
68
742878c74b8e
Lm separation, privacy
Myhailo Danylenko <isbear@ukrpost.net>
parents:
67
diff
changeset
|
293 |
require 'vcard' |
62 | 294 |
|
23
e441162b1386
One pep handler, pep commands
Myhailo Danylenko <isbear@ukrpost.net>
parents:
21
diff
changeset
|
295 |
-- PUBLISH-SUBSRIBE (XEP-0060) |
21 | 296 |
|
68
742878c74b8e
Lm separation, privacy
Myhailo Danylenko <isbear@ukrpost.net>
parents:
67
diff
changeset
|
297 |
require 'pubsub' |
21 | 298 |
|
37 | 299 |
-- OUT OF BAND DATA (XEP-0066) |
300 |
||
68
742878c74b8e
Lm separation, privacy
Myhailo Danylenko <isbear@ukrpost.net>
parents:
67
diff
changeset
|
301 |
require 'oob' |
37 | 302 |
|
62 | 303 |
-- MALICIOUS STANZAS (XEP-0076) |
304 |
||
68
742878c74b8e
Lm separation, privacy
Myhailo Danylenko <isbear@ukrpost.net>
parents:
67
diff
changeset
|
305 |
require 'evil' |
62 | 306 |
|
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
307 |
-- IN-BAND REGISTRATION (XEP-0077) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
308 |
|
68
742878c74b8e
Lm separation, privacy
Myhailo Danylenko <isbear@ukrpost.net>
parents:
67
diff
changeset
|
309 |
require 'register' |
57 | 310 |
|
59 | 311 |
-- USER LOCATION (XEP-0080) |
312 |
||
68
742878c74b8e
Lm separation, privacy
Myhailo Danylenko <isbear@ukrpost.net>
parents:
67
diff
changeset
|
313 |
require 'geoloc' |
59 | 314 |
|
57 | 315 |
-- USER AVATAR (XEP-0084) |
316 |
||
68
742878c74b8e
Lm separation, privacy
Myhailo Danylenko <isbear@ukrpost.net>
parents:
67
diff
changeset
|
317 |
require 'avatar' |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
318 |
|
59 | 319 |
-- USER MOOD (XEP-0107) |
320 |
||
68
742878c74b8e
Lm separation, privacy
Myhailo Danylenko <isbear@ukrpost.net>
parents:
67
diff
changeset
|
321 |
require 'mood' |
59 | 322 |
|
323 |
-- USER ACTIVITY (XEP-0108) |
|
324 |
||
68
742878c74b8e
Lm separation, privacy
Myhailo Danylenko <isbear@ukrpost.net>
parents:
67
diff
changeset
|
325 |
require 'activity' |
59 | 326 |
|
327 |
-- USER TUNE (XEP-0118) |
|
328 |
||
68
742878c74b8e
Lm separation, privacy
Myhailo Danylenko <isbear@ukrpost.net>
parents:
67
diff
changeset
|
329 |
require 'tune' |
59 | 330 |
|
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
331 |
-- REMOTE CONTROLLING CLIENTS (XEP-0146) |
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
332 |
|
68
742878c74b8e
Lm separation, privacy
Myhailo Danylenko <isbear@ukrpost.net>
parents:
67
diff
changeset
|
333 |
require 'remote' |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
334 |
|
23
e441162b1386
One pep handler, pep commands
Myhailo Danylenko <isbear@ukrpost.net>
parents:
21
diff
changeset
|
335 |
-- PERSONAL EVENTING PROTOCOL (XEP-0163) |
e441162b1386
One pep handler, pep commands
Myhailo Danylenko <isbear@ukrpost.net>
parents:
21
diff
changeset
|
336 |
|
57 | 337 |
-- XMPP PING (XEP-0199) |
338 |
||
68
742878c74b8e
Lm separation, privacy
Myhailo Danylenko <isbear@ukrpost.net>
parents:
67
diff
changeset
|
339 |
require 'ping' |
23
e441162b1386
One pep handler, pep commands
Myhailo Danylenko <isbear@ukrpost.net>
parents:
21
diff
changeset
|
340 |
|
50 | 341 |
-- ATTENTION (XEP-0224) |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
342 |
|
68
742878c74b8e
Lm separation, privacy
Myhailo Danylenko <isbear@ukrpost.net>
parents:
67
diff
changeset
|
343 |
require 'attention' |
5
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
344 |
|
cba039bd6f13
Included sample configuration into package
Myhailo Danylenko <isbear@ukrpost.net>
parents:
diff
changeset
|
345 |
-- The End -- vim: se ts=4: -- |