chatlog module
a sample chatlogger included with ps-client
-
class
chatlog.
Chatlogger
(path) Bases:
object
Class for logging chat
Parameters: path (string) – the path to the logging directory -
formatData
(data, isHTML=False) Formats data to text
Parameters: - data (string of form userid|time|type|senderName|body) – the data
- isHTML (bool, optional) – Whether to format as HTML. Defaults to False.
Returns: a human-readable version of the message
Return type: string
-
formatMessage
(message) Formats a message for logging in the data format userid|time|type|senderName|body
Parameters: message (Message) – the message to format Returns: the formatted message Return type: (string)
-
getFile
(roomID, perms) Returns a file object corresponding to the room’s chatlog file.
Parameters: - roomID (string that is an ID) – the room
- perms (string) – the file perms (for example, ‘r’ or ‘w’)
Returns: a file for the log file for that room and day
Return type: File
-
handleMessage
(message) Handles logging a message to chatlogs
Parameters: message (Message) – the Message
-
path
= None the path to log chat to
-
search
(roomID='', userID='', keyword='', includeJoins=False) Searches chatlogs
Parameters: - roomID (str, optional) – The ID of the room to search in. Defaults to “”.
- userID (str, optional) – The ID of the user whose messages are being searched for. Defaults to “”.
- keyword (str, optional) – [description]. Defaults to “”.
Returns: a dictionary of matched messages (formatted as
{date (string): [userid|time|type|senderName|body] (list of day's results)}
)Return type: dictionary
-