Skip to content

âš¡Server Events#

🚀 Events are designed for handling server-related tasks, with a total of 8 events created specifically for this purpose. These events are dispatched to decorators that are subscribed to them.

Note

You are sought to not change or create a custom event, since it still needs to be tested. Without testing, the execution of a custom event might cause problems that server implementations may not be able to deal it causing the server to eventually die.

🚀 Events#

Module for events that get triggered in the Mail.tm server.

This module contains a set of classes representing different events that get triggered in the Mail.tm server. These events can be used to create callbacks for when certain actions happen in the server.

  • NewMessage: Triggered when a new message is received.
  • MessageDelete: Triggered when a message is deleted using the server instance.
  • DomainChange: Triggered when the email domain is changed.
  • AccountSwitched: Triggered when the account is switched to a different account.
  • NewAccountCreated: Triggered when a new account is created.
  • AccountDeleted: Triggered when an account is deleted.
  • ServerStarted: Triggered when the server is started.
  • ServerCalledOff: Triggered when the server is ended.

BaseEvent #

BaseEvent(
    event: str, client: AsyncMail, _server: AttachServer
)

Represents a set of Discord UI components attached to a message.

PARAMETER DESCRIPTION
event

A string attached to the BaseEvent that represents the event.

TYPE: str

client

An instance AsyncMail that represents the client. You can use this to operate the interactions with the AsyncClient

TYPE: AsyncMail

_server

This is not supposed to be used by the user. This attaches a server instance to dispatch events within from events.

TYPE: AttachServer

client property #

client: AsyncMail

Client attached to the server context.

RETURNS DESCRIPTION
AsyncMail

an instance of AsyncMail attached to the server in the context of the interaction.

server property #

server: AttachServer

An instance of AttachServer, which basically has the MailServer attached to it.

RETURNS DESCRIPTION
AttachServer

an instance of AttachServer, which can be used like AttachServer.server. This contains MailServer.

event property #

event: str

The event string associated with the dispatched class.

RETURNS DESCRIPTION
str

The event string associated with the dispatched class

NewMessage #

NewMessage(
    event: str,
    client: AsyncMail,
    _server: AttachServer,
    new_message: Message,
)

Bases: BaseEvent

Event triggered when a message is received.

PARAMETER DESCRIPTION
new_message

The message that was received.

TYPE: Message

client property #

client: AsyncMail

Client attached to the server context.

RETURNS DESCRIPTION
AsyncMail

an instance of AsyncMail attached to the server in the context of the interaction.

server property #

server: AttachServer

An instance of AttachServer, which basically has the MailServer attached to it.

RETURNS DESCRIPTION
AttachServer

an instance of AttachServer, which can be used like AttachServer.server. This contains MailServer.

event property #

event: str

The event string associated with the dispatched class.

RETURNS DESCRIPTION
str

The event string associated with the dispatched class

new_message property #

new_message: Message

The new message that was received from the server.

RETURNS DESCRIPTION
Message

An instance of Message which includes the details about message received from the server.

delete_message async #

delete_message() -> None

Delete the message from the Mail Box.

mark_as_seen async #

mark_as_seen() -> None

Flag the message as seen.

MessageDelete #

MessageDelete(
    event: str,
    client: AsyncMail,
    deleted_message: Message,
    _server: AttachServer,
)

Bases: BaseEvent

Event triggered when a message gets deleted using the server instance. Note: This won't get triggered if the client is used to delete any message

PARAMETER DESCRIPTION
deleted_message

The message that was deleted.

TYPE: Message

client property #

client: AsyncMail

Client attached to the server context.

RETURNS DESCRIPTION
AsyncMail

an instance of AsyncMail attached to the server in the context of the interaction.

server property #

server: AttachServer

An instance of AttachServer, which basically has the MailServer attached to it.

RETURNS DESCRIPTION
AttachServer

an instance of AttachServer, which can be used like AttachServer.server. This contains MailServer.

event property #

event: str

The event string associated with the dispatched class.

RETURNS DESCRIPTION
str

The event string associated with the dispatched class

deleted_message property #

deleted_message: Message

The message that was deleted.

RETURNS DESCRIPTION
Message

The message that was deleted.

DomainChange #

DomainChange(
    new_domain: Domain,
    event: str,
    client: AsyncMail,
    _server: AttachServer,
)

Bases: BaseEvent

Event triggered when the email domain is changed.

Parameter

new_domain : Domain The new domain that was set.

client property #

client: AsyncMail

Client attached to the server context.

RETURNS DESCRIPTION
AsyncMail

an instance of AsyncMail attached to the server in the context of the interaction.

server property #

server: AttachServer

An instance of AttachServer, which basically has the MailServer attached to it.

RETURNS DESCRIPTION
AttachServer

an instance of AttachServer, which can be used like AttachServer.server. This contains MailServer.

event property #

event: str

The event string associated with the dispatched class.

RETURNS DESCRIPTION
str

The event string associated with the dispatched class

new_domain property #

new_domain: Domain

The domain that got changed.

RETURNS DESCRIPTION
Domain

A domain that was changed

AccountSwitched #

AccountSwitched(
    event: str,
    client: AsyncMail,
    _server: AttachServer,
    last_account_auth: ServerAuth,
)

Bases: BaseEvent

Event triggered when the account is switched to a different account.

Parameter

last_account_auth: ServerAuth An instance of ServerAuth that represents the last account.

client property #

client: AsyncMail

Client attached to the server context.

RETURNS DESCRIPTION
AsyncMail

an instance of AsyncMail attached to the server in the context of the interaction.

server property #

server: AttachServer

An instance of AttachServer, which basically has the MailServer attached to it.

RETURNS DESCRIPTION
AttachServer

an instance of AttachServer, which can be used like AttachServer.server. This contains MailServer.

event property #

event: str

The event string associated with the dispatched class.

RETURNS DESCRIPTION
str

The event string associated with the dispatched class

last_account_auth property #

last_account_auth: ServerAuth

Get the ServerAuth of the last account.

Returns:

ServerAuth An instance of ServerAuth that represents the last account.

NewAccountCreated #

NewAccountCreated(
    new_account_auth: ServerAuth,
    new_account: Account,
    event: str,
    client: AsyncMail,
    _server: AttachServer,
)

Bases: BaseEvent

Event triggered when a new account is created.

PARAMETER DESCRIPTION
new_account_auth

An instance of ServerAuth that represents the new account.

TYPE: ServerAuth

new_account

An instance of Account that represents the new account.

TYPE: Account

client property #

client: AsyncMail

Client attached to the server context.

RETURNS DESCRIPTION
AsyncMail

an instance of AsyncMail attached to the server in the context of the interaction.

server property #

server: AttachServer

An instance of AttachServer, which basically has the MailServer attached to it.

RETURNS DESCRIPTION
AttachServer

an instance of AttachServer, which can be used like AttachServer.server. This contains MailServer.

event property #

event: str

The event string associated with the dispatched class.

RETURNS DESCRIPTION
str

The event string associated with the dispatched class

new_account_auth property #

new_account_auth: ServerAuth

The server authentication related to the new account.

RETURNS DESCRIPTION
ServerAuth

An instance representing the details used in server authentication.

TYPE: ServerAuth

new_account property #

new_account: Account

The new account that was created.

RETURNS DESCRIPTION
Account

An instance of Account that represents the new account.

AccountDeleted #

AccountDeleted(
    event: str, client: AsyncMail, _server: AttachServer
)

Bases: BaseEvent

Event triggered when an account is deleted.

client property #

client: AsyncMail

Client attached to the server context.

RETURNS DESCRIPTION
AsyncMail

an instance of AsyncMail attached to the server in the context of the interaction.

server property #

server: AttachServer

An instance of AttachServer, which basically has the MailServer attached to it.

RETURNS DESCRIPTION
AttachServer

an instance of AttachServer, which can be used like AttachServer.server. This contains MailServer.

event property #

event: str

The event string associated with the dispatched class.

RETURNS DESCRIPTION
str

The event string associated with the dispatched class

ServerStarted #

ServerStarted(
    event: str, client: AsyncMail, _server: AttachServer
)

Bases: BaseEvent

Event triggered when the server is started.

client property #

client: AsyncMail

Client attached to the server context.

RETURNS DESCRIPTION
AsyncMail

an instance of AsyncMail attached to the server in the context of the interaction.

server property #

server: AttachServer

An instance of AttachServer, which basically has the MailServer attached to it.

RETURNS DESCRIPTION
AttachServer

an instance of AttachServer, which can be used like AttachServer.server. This contains MailServer.

event property #

event: str

The event string associated with the dispatched class.

RETURNS DESCRIPTION
str

The event string associated with the dispatched class

ServerCalledOff #

ServerCalledOff(
    event: str, client: AsyncMail, _server: AttachServer
)

Bases: BaseEvent

Event triggered when the server is ended.

client property #

client: AsyncMail

Client attached to the server context.

RETURNS DESCRIPTION
AsyncMail

an instance of AsyncMail attached to the server in the context of the interaction.

server property #

server: AttachServer

An instance of AttachServer, which basically has the MailServer attached to it.

RETURNS DESCRIPTION
AttachServer

an instance of AttachServer, which can be used like AttachServer.server. This contains MailServer.

event property #

event: str

The event string associated with the dispatched class.

RETURNS DESCRIPTION
str

The event string associated with the dispatched class