User Object

Note, this class should not be used by you. Only use the AntiSpamHandler to work with this package.

class antispam.user.User(bot, member_id, guild_id, options)

A class dedicated to maintaining a member, and any relevant messages in a single guild.

__eq__(other)

This is called with a ‘obj1 == obj2’ comparison object is made

Checks against stored id’s to figure out if they are representing the same User or not

Parameters:other (User) – The object to compare against
Returns:True or False depending on whether they are the same or not
Return type:bool
Raises:ValueError – When the comparison object is not of ignore_type Message
__hash__()

Given we create a __eq__ dunder method, we also needed to create one for __hash__ lol

Returns:The hash of all id’s
Return type:int
__init__(bot, member_id, guild_id, options)

Set the relevant information in order to maintain and use a per User object for a guild

Parameters:
  • bot (commands.bot) – Bot instance
  • member_id (int) – The relevant member id
  • guild_id (int) – The guild (id) this member is belonging to
  • options (Dict) – The options we need to check against
__module__ = 'antispam.user'
__repr__()

Return repr(self).

__slots__ = ['_id', '_guild_id', '_messages', '_options', 'warn_count', 'kick_count', 'bot', 'in_guild', 'duplicate_counter', 'duplicate_channel_counter_dict']
__str__()

Return str(self).

bot
clean_up(current_time)

This logic works around checking the current time vs a messages creation time. If the message is older by the config amount it can be cleaned up

duplicate_channel_counter_dict
duplicate_counter
get_correct_duplicate_count(channel_id: int = None)

Given the internal math has an extra number cos accuracy this simply returns the correct value

Parameters:channel_id (int) – The channel to get duplicate counters in
Returns:The correct duplicate count
Return type:int
guild_id
id
in_guild
kick_count
static load_from_dict(bot, user_data)

Loads a new user obj from a dict

Parameters:
  • bot (commands.Bot) – The bot
  • user_data (dict) – The data to load state from
Returns:

Return type:

User

messages
options
propagate(value: discord.message.Message)

This method handles a message object and then adds it to the relevant member

Parameters:value (discord.Message) – The message that needs to be propagated out

Warning

Calling this method yourself will bypass all checks

save_to_dict() → dict

Returns a dictionary that can be used to reload state at a later date

Returns:The state to reload from
Return type:dict
warn_count