modbot.connection.pubsub_client.WebSocketClientAsync
- class modbot.connection.pubsub_client.WebSocketClientAsync(run_config)[source]
Bases:
Logging
,BaseSocketClientAsync
Class to handle PubSub connection
Methods
EXTRA_VERBOSE_LOGGER
(message, *args, **kws)Chat log level
INFO_LOGGER
(message, *args, **kws)Chat log level
VERBOSE_LOGGER
(message, *args, **kws)Chat log level
append_log
(line)Add entry to log
build_action_log_entry
(action, user, ...)Build action log entry from message content
build_chat_log_entry
(info)Build standard chat message log entry
connect
()Report initial connection
connect_fail
(e)Response to connection failure
Generate nonce value.
get_info_from_pubsub
(msg_dict)Get info from PubSub message for logging
get_user_id
(user)Get moderator user id
get_value
(key, dictionary)Search nested dictionary for key
handle_message
(message)Handle moderation decisions based on PubSub message
Keep PubSub connection alive
initialize_logger
(run_config)Initialize private logger
Listen for socket connection
quit
()Close pubsub connection
receive_fail
(e)Response to message receive failure
Recieve PubSub message
Send ping to keep connection alive
Attributes
Log handling class
ID for channel to moderate
ID for bot username
- EXTRA_VERBOSE_LOGGER(message, *args, **kws)
Chat log level
- INFO_LOGGER(message, *args, **kws)
Chat log level
- USER_LOG = {}
Log handling class
- VERBOSE_LOGGER(message, *args, **kws)
Chat log level
- append_log(line)
Add entry to log
- Parameters
line (str) – Line to write to log after some sanitizing
- static build_action_log_entry(action, user, moderator, msg, secs, msg_id)
Build action log entry from message content
- Parameters
action (str) – Moderation action. e.g ban, timeout, delete
user (str) – Username
moderator (str) – Moderator username who performed action
msg (str) – The message which preceeded the mod action
secs (str) – Timeout length in seconds
msg_id (str) – Message id
- Returns
Log entry containing moderation action info
- Return type
str
- static build_chat_log_entry(info)
Build standard chat message log entry
- Parameters
info (dict) – Dictionary of info from IRC message
- Returns
Chat log entry to write to log
- Return type
str
- property channel_id
ID for channel to moderate
- connect_fail(e)
Response to connection failure
- get_info_from_pubsub(msg_dict)
Get info from PubSub message for logging
- Parameters
msg_dict (dict) – Dictionary containing PubSub message info
- Returns
action (str) – Moderation action. e.g ban, timeout, delete
user (str) – Username
moderator (str) – Moderator username who performed action
msg (str) – The message which preceeded the mod action
secs (str) – Timeout length in seconds
msg_id (str) – Message id
- get_user_id(user)[source]
Get moderator user id
- Parameters
user (str) – User for which to get id
- Returns
User id
- Return type
str
- static get_value(key, dictionary)
Search nested dictionary for key
- Parameters
key (str) – Key to search dictionary for
dictionary (dict) – Dictionary to search key for
- Returns
Value in dictionary corresponding to key, or empty string if not found
- Return type
str
- async handle_message(message)[source]
Handle moderation decisions based on PubSub message
- Parameters
message (str) – String containing PubSub message
- initialize_logger(run_config)
Initialize private logger
- Parameters
run_config (RunConfig) – RunConfig class storing run time configuration parameters
- Returns
Private logger used to write chat messages and mod actions
- Return type
logger
- async listen_forever()
Listen for socket connection
- property moderator_id
ID for bot username
- receive_fail(e)
Response to message receive failure