-
-
Notifications
You must be signed in to change notification settings - Fork 409
core: better bot-mode handling #2448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9e8a01d
core_section: remove default `B` mode from `modes` setting
dgw a5de5b1
tools.target: add `is_bot` attribute to User object
dgw 8c54861
coretasks: update `User.is_bot` attribute if possible from WHO replies
dgw e82c94f
tools.target: finish type-hinting module
dgw d654a21
docs: note automatic use of bot-mode + alternative `modes` setting
dgw 7feeaf5
coretasks: type-hint `_record_who()`
dgw ab9969f
tools.target: better docstrings about `User` attrs that can be `None`
dgw e90317d
tests: basic test cases for `coretasks.recv_who()`
dgw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ class User: | |
| :param str host: the user's hostname ("host.name" in `[email protected]`) | ||
| """ | ||
| __slots__ = ( | ||
| 'nick', 'user', 'host', 'realname', 'channels', 'account', 'away', | ||
| 'nick', 'user', 'host', 'realname', 'channels', 'account', 'away', 'is_bot', | ||
| ) | ||
|
|
||
| def __init__( | ||
|
|
@@ -33,34 +33,62 @@ def __init__( | |
| host: Optional[str], | ||
| ) -> None: | ||
| assert isinstance(nick, identifiers.Identifier) | ||
| self.nick = nick | ||
| self.nick: identifiers.Identifier = nick | ||
| """The user's nickname.""" | ||
| self.user = user | ||
| """The user's local username.""" | ||
| self.host = host | ||
| """The user's hostname.""" | ||
| self.realname = None | ||
| self.user: Optional[str] = user | ||
| """The user's local username. | ||
|
|
||
| Will be ``None`` if Sopel has not yet received complete user | ||
| information from the IRC server. | ||
| """ | ||
| self.host: Optional[str] = host | ||
| """The user's hostname. | ||
|
|
||
| Will be ``None`` if Sopel has not yet received complete user | ||
| information from the IRC server. | ||
| """ | ||
| self.realname: Optional[str] = None | ||
| """The user's realname. | ||
|
|
||
| Will be ``None`` if not received from the server yet. | ||
| Will be ``None`` if Sopel has not yet received complete user | ||
| information from the IRC server. | ||
| """ | ||
| self.channels: Dict[identifiers.Identifier, 'Channel'] = {} | ||
| """The channels the user is in. | ||
|
|
||
| This maps channel name :class:`~sopel.tools.identifiers.Identifier`\\s | ||
| to :class:`Channel` objects. | ||
| """ | ||
| self.account = None | ||
| self.account: Optional[str] = None | ||
| """The IRC services account of the user. | ||
|
|
||
| This relies on IRCv3 account tracking being enabled. | ||
|
|
||
| Will be ``None`` if the user is not logged into an account (including | ||
| when account tracking is not supported by the IRC server.) | ||
| """ | ||
| self.away = None | ||
| """Whether the user is marked as away.""" | ||
| self.away: Optional[bool] = None | ||
| """Whether the user is marked as away. | ||
|
|
||
| hostmask = property(lambda self: '{}!{}@{}'.format(self.nick, self.user, | ||
| self.host)) | ||
| """The user's full hostmask.""" | ||
| Will be ``None`` if the user's current away state hasn't been | ||
| established yet (via WHO or other means such as ``away-notify``). | ||
| """ | ||
| self.is_bot: Optional[bool] = None | ||
| """Whether the user is flagged as a bot. | ||
|
|
||
| Will be ``None`` if the user hasn't yet been WHOed, or if the IRC | ||
| server does not support a 'bot' user mode. | ||
| """ | ||
|
|
||
| @property | ||
| def hostmask(self) -> str: | ||
| """The user's full hostmask (``nick!user@host``).""" | ||
| # TODO: this won't work as expected if `user`/`host` is still `None` | ||
| return '{}!{}@{}'.format( | ||
| self.nick, | ||
| self.user, | ||
| self.host, | ||
| ) | ||
|
|
||
| def __eq__(self, other: Any) -> bool: | ||
| if not isinstance(other, User): | ||
|
|
@@ -99,7 +127,7 @@ def __init__( | |
| identifier_factory: IdentifierFactory = identifiers.Identifier, | ||
| ) -> None: | ||
| assert isinstance(name, identifiers.Identifier) | ||
| self.name = name | ||
| self.name: identifiers.Identifier = name | ||
| """The name of the channel.""" | ||
|
|
||
| self.make_identifier: IdentifierFactory = identifier_factory | ||
|
|
@@ -133,7 +161,7 @@ def __init__( | |
| bitwise integer values. This can be compared to appropriate constants | ||
| from :mod:`sopel.privileges`. | ||
| """ | ||
| self.topic = '' | ||
| self.topic: str = '' | ||
| """The topic of the channel.""" | ||
|
|
||
| self.modes: Dict[str, Union[Set, str, bool]] = {} | ||
|
|
||
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.