-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
=
committed
Dec 11, 2023
1 parent
a7eb428
commit e58be4f
Showing
4 changed files
with
58 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,37 @@ | ||
from abc import ABC | ||
from typing import Callable, TypeVar | ||
from typing import Any, Callable, Generic, Protocol, TypeVar | ||
|
||
from _typeshed import Incomplete | ||
|
||
from mmpy_bot.plugins import Plugin as Plugin | ||
from mmpy_bot.utils import completed_future as completed_future | ||
from mmpy_bot.webhook_server import NoResponse as NoResponse | ||
from mmpy_bot.wrappers import Message as Message | ||
from mmpy_bot.wrappers import WebHookEvent as WebHookEvent | ||
|
||
log: Incomplete | ||
ReturningType = TypeVar("ReturningType") | ||
ReturningType = TypeVar("ReturningType", covariant=True) | ||
|
||
class MessageFunction(Protocol, Generic[ReturningType]): | ||
async def __call__(self_, self: Plugin, message: Message, *args) -> ReturningType: ... # type: ignore | ||
|
||
def listen_to( | ||
regexp: str, | ||
regexp_flag: int = ..., | ||
regexp_flag: int = 0, | ||
*, | ||
direct_only: bool = ..., | ||
needs_mention: bool = ..., | ||
allowed_users: Incomplete | None = ..., | ||
allowed_channels: Incomplete | None = ..., | ||
silence_fail_msg: bool = ..., | ||
**metadata: dict[Incomplete, Incomplete] | ||
) -> Callable[[Callable[..., ReturningType]], ReturningType]: ... | ||
direct_only: bool = False, | ||
needs_mention: bool = False, | ||
allowed_users: Any = None, | ||
allowed_channels: Any = None, | ||
silence_fail_msg: Any = False, | ||
**metadata: dict[str, Any], | ||
) -> Callable[[Callable[..., ReturningType]], MessageFunction[ReturningType]]: | ||
"""Wrap the given function in a MessageFunction class so we can register some | ||
properties.""" | ||
|
||
def listen_webhook( | ||
regexp: str, **metadata: dict[Incomplete, Incomplete] | ||
) -> Callable[[Callable[..., ReturningType]], ReturningType]: ... | ||
) -> Callable[[Callable[..., ReturningType]], Callable[..., ReturningType]]: ... | ||
|
||
class Function(ABC): ... | ||
class MessageFunction(Function): ... | ||
class WebHookFunction(Function): ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters