modbot.preprocessing.MsgMemory

class modbot.preprocessing.MsgMemory(config=None)[source]

Bases: object

Class to store messages and message info

Methods

add_msg(info)

Add message to memory

build_full_memory(lines)

Build full memory for all lines

check_msgs(user)

Check if user has messages in memory dictionary

chunk_memory()

Chunk memory.

chunk_recent(info)

Join number of past messages into a single string to use for model prediction

clear_user(user)

Clear memory for user

del_msg(user)

Remove message from memory dictionary

update_banned_status(line)

Update banned status for user log

update_deleted_status(line)

Update deleted status for user log

update_mod_action_status(line)

Update mod action status for user log

update_user_ban(user[, banned])

Update the ban status of the user

add_msg(info)[source]

Add message to memory

Parameters

info (dict) – Dictionary containing user info

build_full_memory(lines)[source]

Build full memory for all lines

Parameters

lines (list) – List of lines from which to build memory

check_msgs(user)[source]

Check if user has messages in memory dictionary

Parameters

user (str) – Username to check messages for

chunk_memory()[source]

Chunk memory. Group messages by user and by chunk size so that more than one message can be taken into account for moderation.

chunk_recent(info)[source]

Join number of past messages into a single string to use for model prediction

Parameters

info (dict) – Dictionary containing user info

Returns

String containing joined messages

Return type

str

clear_user(user)[source]

Clear memory for user

Parameters

user (str) – Username to clear memory for

del_msg(user)[source]

Remove message from memory dictionary

Parameters

user (str) – Username to remove from memory

update_banned_status(line)[source]

Update banned status for user log

Parameters

line (str) – Log line that could contain a user name

update_deleted_status(line)[source]

Update deleted status for user log

Parameters

line (str) – Log line that could contain a user name

update_mod_action_status(line)[source]

Update mod action status for user log

Parameters

line (str) – Log line that could contain a user name

update_user_ban(user, banned=True)[source]

Update the ban status of the user

Parameters
  • user (str) – Username to use for updating

  • banned (bool) – Whether the user was banned or not