Software /
code /
prosody
Annotate
util/hex.lua @ 6429:675aea867574
plugins/muc: Add muc-occupant-groupchat event
- Plugins can cancel messages before they are broadcast; and while they still have real from jid
- Use it for subject changes
- Allows for custom roles (via role_rank)
- Roles are now checked before subject
- Removed muc-subject-change event
author | daurnimator <quae@daurnimator.com> |
---|---|
date | Thu, 25 Sep 2014 17:43:00 -0400 |
parent | 6384:3f4809d01783 |
child | 6545:ec566d7cd518 |
rev | line source |
---|---|
6375
76d8907d5301
util.hex: Small util lib for converting to/from hex strings
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 local s_char = string.char; |
76d8907d5301
util.hex: Small util lib for converting to/from hex strings
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 |
76d8907d5301
util.hex: Small util lib for converting to/from hex strings
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 local function char_to_hex(c) |
76d8907d5301
util.hex: Small util lib for converting to/from hex strings
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 return ("%02x"):format(c:byte()) |
76d8907d5301
util.hex: Small util lib for converting to/from hex strings
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 end |
76d8907d5301
util.hex: Small util lib for converting to/from hex strings
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 |
76d8907d5301
util.hex: Small util lib for converting to/from hex strings
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 local function hex_to_char(h) |
76d8907d5301
util.hex: Small util lib for converting to/from hex strings
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 return s_char(tonumber(h, 16)); |
76d8907d5301
util.hex: Small util lib for converting to/from hex strings
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 end |
76d8907d5301
util.hex: Small util lib for converting to/from hex strings
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 |
6384 | 11 local function to(s) |
6375
76d8907d5301
util.hex: Small util lib for converting to/from hex strings
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 return s:gsub(".", char_to_hex); |
76d8907d5301
util.hex: Small util lib for converting to/from hex strings
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 end |
76d8907d5301
util.hex: Small util lib for converting to/from hex strings
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 |
6384 | 15 local function from(s) |
6375
76d8907d5301
util.hex: Small util lib for converting to/from hex strings
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 return s:gsub("..", hex_to_char); |
76d8907d5301
util.hex: Small util lib for converting to/from hex strings
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 end |
76d8907d5301
util.hex: Small util lib for converting to/from hex strings
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 |
76d8907d5301
util.hex: Small util lib for converting to/from hex strings
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 return { to = to, from = from } |