4545
4646from sopel import tools , trigger
4747from sopel .lifecycle import deprecated
48- from sopel .tools import identifiers
48+ from sopel .tools import identifiers , memories
4949from .backends import AsyncioBackend , UninitializedBackend
5050from .capabilities import Capabilities
5151from .isupport import ISupport
@@ -227,7 +227,10 @@ def hostmask(self) -> Optional[str]:
227227 # Utility
228228
229229 def make_identifier (self , name : str ) -> identifiers .Identifier :
230- """Instantiate an Identifier using the bot's context."""
230+ """Instantiate an Identifier using the bot's context.
231+
232+ .. versionadded:: 8.0
233+ """
231234 casemapping = {
232235 'ascii' : identifiers .ascii_lower ,
233236 'rfc1459' : identifiers .rfc1459_lower ,
@@ -242,6 +245,36 @@ def make_identifier(self, name: str) -> identifiers.Identifier:
242245 chantypes = chantypes ,
243246 )
244247
248+ def make_identifier_memory (self ) -> memories .SopelIdentifierMemory :
249+ """Instantiate a SopelIdentifierMemory using the bot's context.
250+
251+ This is a shortcut for :class:`~.memories.SopelIdentifierMemory`\' s most
252+ common use case, which requires remembering to pass the ``bot``\' s own
253+ :meth:`make_identifier` method so the ``SopelIdentifierMemory`` will
254+ cast its keys to :class:`~.tools.identifiers.Identifier`\\ s that are
255+ compatible with what the bot tracks internally and sends with
256+ :class:`~.trigger.Trigger`\\ s when a plugin callable runs.
257+
258+ Calling this method is equivalent to the following::
259+
260+ from sopel.tools import memories
261+
262+ memories.SopelIdentifierMemory(
263+ identifier_factory=bot.make_identifier,
264+ )
265+
266+ .. versionadded:: 8.0
267+
268+ .. seealso::
269+
270+ The :mod:`.tools.memories` module describes how to use
271+ :class:`~.tools.memories.SopelIdentifierMemory` and its siblings.
272+
273+ """
274+ return memories .SopelIdentifierMemory (
275+ identifier_factory = self .make_identifier ,
276+ )
277+
245278 def safe_text_length (self , recipient : str ) -> int :
246279 """Estimate a safe text length for an IRC message.
247280
0 commit comments