+-- parse_user {{{
+---
+-- Gets the various parts of a full username.
+-- @param user A usermask (i.e. returned in the from field of a callback)
+-- @return nick
+-- @return username (if it exists)
+-- @return hostname (if it exists)
+function parse_user(user)
+ local found, bang, nick = user:find("^([^!]*)!")
+ if found then
+ user = user:sub(bang + 1)
+ else
+ return user
+ end
+ local found, equals = user:find("^.=")
+ if found then
+ user = user:sub(3)
+ end
+ local found, at, username = user:find("^([^@]*)@")
+ if found then
+ return nick, username, user:sub(at + 1)
+ else
+ return nick, user
+ end
+end
+-- }}}
+
+-- split {{{
+--
+-- Splits str into substrings based on several options.
+-- @param str String to split
+-- @param delim String of characters to use as the beginning of substring
+-- delimiter
+-- @param end_delim String of characters to use as the end of substring
+-- delimiter
+-- @param lquotes String of characters to use as opening quotes (quoted strings
+-- in str will be considered one substring)
+-- @param rquotes String of characters to use as closing quotes
+-- @return Array of strings, one for each substring that was separated out