MemoryCache Reference¶
This is the default cache for the package. You shouldn’t need to implement it yourself.
Furthermore, refer to antispam.abc.Cache
for protocol implementation.
-
class
antispam.caches.
MemoryCache
(handler)¶ -
__init__
(handler)¶ Initialize self. See help(type(self)) for accurate signature.
-
add_message
(message: antispam.dataclasses.message.Message) → None¶ Adds a Message to the relevant Member, creating the Guild/Member if they don’t exist
Parameters: message (Message) – The Message to add to the internal cache Notes
This should silently create any Guild’s/Member’s required to fulfil this transaction
-
delete_guild
(guild_id: int) → None¶ Removes a guild from the cache.
Parameters: guild_id (int) – The id of the guild we wish to remove Notes
This fails silently.
-
delete_member
(member_id: int, guild_id: int) → None¶ Removes a member from the cache.
Parameters: Notes
This fails silently.
-
drop
() → None¶ Drops the entire cache, deleting everything contained within.
-
get_all_guilds
() → AsyncIterable[antispam.dataclasses.guild.Guild]¶ Returns a generator containing all cached guilds
Yields: Guild – A generator of all stored guilds
-
get_all_members
(guild_id: int) → AsyncIterable[antispam.dataclasses.member.Member]¶ Fetches all members within a guild and returns them within a generator
Parameters: guild_id (int) – The guild we want members in Yields: Member – All members in the given guild Raises: GuildNotFound
– The given guild was not found
-
get_guild
(guild_id: int) → antispam.dataclasses.guild.Guild¶ Fetch a Guild dataclass populated with members
Parameters: guild_id (int) – The id of the Guild to retrieve from cache Raises: GuildNotFound
– A Guild could not be found in the cache with the given id
-
get_member
(member_id: int, guild_id: int) → antispam.dataclasses.member.Member¶ Fetch a Member dataclass populated with messages
Parameters: Raises: MemberNotFound
– This Member could not be found on the associated Guild within the internal cacheGuildNotFound
– The relevant guild could not be found
-
initialize
(*args, **kwargs) → None¶ This method gets called once when the AntiSpamHandler init() method gets called to allow for setting up connections, etc
Notes
This is not required.
-
reset_member_count
(member_id: int, guild_id: int, reset_type: antispam.enums.reset_type.ResetType) → None¶ Reset the chosen enum type back to the default value
Parameters:
-