MiddlewarePlugin<CTX extends Context> class abstract

Base class for plugins that only provide middleware.

This is a convenience base class for plugins that only need to add middleware to the bot. Subclasses need only implement the middleware getter.

Example:

class LoggingPlugin<CTX extends Context> extends MiddlewarePlugin<CTX> {
  @override
  String get name => 'logging';

  @override
  String get description => 'Logs all incoming updates';

  @override
  Middleware<CTX> get middleware => (ctx, next) async {
    print('📥 Update ${ctx.update.updateId}');
    await next();
    print('✅ Update ${ctx.update.updateId} processed');
  };
}
Implemented types

Constructors

MiddlewarePlugin()

Properties

dependencies → List<String>
List of plugin names that this plugin depends on.
no setterinherited
description → String?
Optional description of what this plugin does.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
middleware → Middleware<CTX>
The middleware function to install.
no setter
name → String
The unique name of this plugin.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
version → String
The version of this plugin.
no setterinherited

Methods

install(Bot<CTX> bot) → void
Installs the plugin on the given bot.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
uninstall(Bot<CTX> bot) → void
Uninstalls the plugin from the given bot.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited