hook.alerts

class immp.hook.alerts.SubTrigger(**kwargs: typing.Any) → None

Bases: tortoise.models.Model

Individual subscription trigger phrase for an individual user.

network

str – Network identifier that the user belongs to.

user

str – User identifier as given by the plug.

text

str – Subscription text that they wish to be notified on.

class immp.hook.alerts.SubExclude(**kwargs: typing.Any) → None

Bases: tortoise.models.Model

Exclusion for a trigger in a specific channel.

trigger

.SubTrigger – Containing trigger instance.

network

str – Network identifier that the channel belongs to.

user

str – Channel’s own identifier.

class immp.hook.alerts.MentionsHook(name, config, host, virtual=False)

Bases: immp.hook.alerts._AlertHookBase

Hook to send mention alerts via private channels.

match(mention, members)

Identify users relevant to a mention.

Parameters
  • mention (str) – Raw mention text, e.g. @fred.
  • members (User list) – List of members in the channel where the mention took place.
Returns

All applicable members to be notified.

Return type

User set

class immp.hook.alerts.SubscriptionsHook(name, config, host, virtual=False)

Bases: immp.hook.alerts._AlertHookBase

Hook to send trigger word alerts via private channels.

static match(text, channel, present)

Identify users subscribed to text snippets in a message.

Parameters
  • text (str) – Cleaned message text.
  • channel (Channel) – Channel where the subscriptions were triggered.
  • present (((str, str), User) dict) – Mapping from network/user IDs to members of the source channel.
Returns

Mapping from applicable users to their filtered triggers.

Return type

(User, str set) dict