Module irccd.util
Utilitities.
Some utilities.
Functions
-
basename (path)
-
Get the file name of a full path. (deprecated)
Returns the file name only of a full path. For instance, returns
"foo.lua" when calling with "/usr/local/foo.lua"
Parameters:
Returns:
the file name
See also:
-
date (timestamp)
-
Create a Date object.
This function returns a date object with a specific time from the
system. If no timestamp is provided, it use the current date.
Parameters:
- timestamp
an optional timestamp
Returns:
a Date object
See also:
-
dirname (path)
-
Get the parent path of a file. (deprecated)
This function may be used to get the parent path of a file. Example:
calling dirname on "/foo/bar/test.txt" will returns "/foo/bar".
Parameters:
Returns:
the parent path
See also:
-
exist (path)
-
Check if a file exists. (deprecated)
Tests if a directory or a file exists.
Parameters:
Returns:
true if exists
See also:
-
format (text, attrs)
-
Format text with colors and attributes.
The table attrs may have the following fields:
- fg (int): the foreground color
- bg (int): the background color
- attrs (table or int): may be a sequence or one attribute
Note: some attributes are not available on all IRC servers and
colours are based on mIRC, nothing standard.
Parameters:
- text
the text to format
- attrs
the parameters, see above
Returns:
a string ready to be sent
See also:
-
getEnv ()
-
Get a environment variable. (deprecated)
Returns:
the variable or an empty string
See also:
-
getHome ()
-
Get the home directory. (deprecated)
This function should be used with care, plugin should not use user home to
store files.
Returns:
the user home directory
See also:
-
getTicks ()
-
Get the time spent from start. (deprecated)
Get how many milliseconds spent since the irccd startup.
Returns:
the number of seconds
See also:
-
mkdir (path, mode)
-
Create a directory recursively. (deprecated)
This function acts like
mkdir -p
.
Parameters:
- path
the path
- mode
an optional octal mode
Returns:
-
true on success or false plus an error
-
the error message
See also:
-
opendir (path, skipSpecial)
-
Open a directory. (deprecated)
Optional boolean skipSpecial may be passed to avoid ".", ".." for being
included.
Parameters:
- path
the path
- skipSpecial
forget "." and "..", default: false
Returns:
a Directory object
See also:
-
splitUser (user)
-
Split the nickname and host. (deprecated)
Extract the nickname and host from a user, for instance with
foo!~foo@localhost, foo will be returned as first value, localhost
as second.
Parameters:
Returns:
-
the nickname
-
the hostname
-
splituser (user)
-
Split the nickname.
Extract the nickname from a user, for instance with
foo!~foo@localhost, foo will be returned.
Parameters:
Returns:
the nickname
-
splithost (user)
-
Split the hostname.
Extract the hostname from a user, for instance with
foo!~foo@localhost, localhost will be returned.
Parameters:
Returns:
the nickname
-
usleep (msec)
-
Sleep for milliseconds. (deprecated)
Suspend the execution thread.
Parameters:
- msec
the number of milliseconds
See also:
Tables
-
color
-
Colors
Fields:
- White
White.
- Black
Black.
- Blue
Blue.
- Green
Green.
- Red
Red.
- Brown
Brown.
- Purple
Purple.
- Orange
Orange.
- Yellow
Yellow.
- LightGreen
LightGreen.
- Cyan
Cyan.
- LightCyan
LightCyan.
- LightBlue
LightBlue.
- Pink
Pink.
- Grey
Grey.
- LightGrey
LightGrey.
-
attribute
-
Attributes
Fields:
- Bold
Bold.
- Color
Color (start a color sequence).
- Italic
Italic.
- StrikeThrough
StrikeThrough.
- Reset
Reset (remove all formatting).
- Underline
Underline1.
- Underline2
Underline2.
- Reverse
Reverse (reverse foreground and background).
Class Date
-
Date:calendar ()
-
Get a calendar.
Return a table with the following fields:
- seconds (int): seconds elapsed [0-60]
- minutes (int): minutes elapsed [0-59]
- hours (int): hours elapsed [0-23]
- month (int): number of month [1-12]
- year (int): the real year
Returns:
a table
-
Date:format (format)
-
Format a date with a format.
See the manual strftime(3) for keywords.
Parameters:
Returns:
the date formatted
-
Date:timestamp ()
-
Return the timestamp.
Get the timestamp from the epoch (aka time_t).
Returns:
a timestamp
Date metamethods
The metamethods available for object Date.
-
Date:__eq (other)
-
Test equality.
Parameters:
Returns:
true if they equals
-
Date:__le (other)
-
Test inferiority
Parameters:
Returns:
self <= other comparison
-
Date:__tostring ()
-
Convert object to string.
Returns:
a string