index
int64
0
731k
package
stringlengths
2
98
name
stringlengths
1
76
docstring
stringlengths
0
281k
code
stringlengths
4
1.07M
signature
stringlengths
2
42.8k
42,312
pydle.features.ircv3.cap
_capability_normalize
null
def _capability_normalize(self, cap): cap = cap.lstrip(PREFIXES).lower() if CAPABILITY_VALUE_DIVIDER in cap: cap, _, value = cap.partition(CAPABILITY_VALUE_DIVIDER) else: value = None return cap, value
(self, cap)
42,313
pydle.features.tls
_connect
Connect to IRC server, optionally over TLS.
def __init__(self, *args, tls_client_cert=None, tls_client_cert_key=None, tls_client_cert_password=None, **kwargs): super().__init__(*args, **kwargs) self.tls_client_cert = tls_client_cert self.tls_client_cert_key = tls_client_cert_key self.tls_client_cert_password = tls_client_cert_password
(self, hostname, port, reconnect=False, password=None, encoding='utf-8', channels=None, tls=False, tls_verify=False, source_address=None)
42,314
pydle.features.isupport
_create_channel
Create channel with optional ban and invite exception lists.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, channel)
42,315
pydle.features.ircv3.tags
_create_message
null
def _create_message(self, command, *params, tags=None, **kwargs): message = super()._create_message(command, *params, **kwargs) return TaggedMessage(tags=tags or {}, **message._kw)
(self, command, *params, tags=None, **kwargs)
42,316
pydle.features.whox
_create_user
null
## whox.py # WHOX support. from pydle.features import isupport, account NO_ACCOUNT = '0' # Maximum of 3 characters because Charybdis stupidity. The ASCII values of 'pydle' added together. WHOX_IDENTIFIER = '542' class WHOXSupport(isupport.ISUPPORTSupport, account.AccountSupport): ## Overrides. async def on_raw_join(self, message): """ Override JOIN to send WHOX. """ await super().on_raw_join(message) nick, metadata = self._parse_user(message.source) channels = message.params[0].split(',') if self.is_same_nick(self.nickname, nick): # We joined. if 'WHOX' in self._isupport and self._isupport['WHOX']: # Get more relevant channel info thanks to WHOX. await self.rawmsg('WHO', ','.join(channels), '%tnurha,{id}'.format(id=WHOX_IDENTIFIER)) else: # Find account name of person. pass async def _create_user(self, nickname): super()._create_user(nickname) if self.registered and 'WHOX' not in self._isupport: await self.whois(nickname) async def on_raw_354(self, message): """ WHOX results have arrived. """ # Is the message for us? target, identifier = message.params[:2] if identifier != WHOX_IDENTIFIER: return # Great. Extract relevant information. metadata = { 'nickname': message.params[4], 'username': message.params[2], 'realname': message.params[6], 'hostname': message.params[3], } if message.params[5] != NO_ACCOUNT: metadata['identified'] = True metadata['account'] = message.params[5] await self._sync_user(metadata['nickname'], metadata)
(self, nickname)
42,318
pydle.features.ircv3.monitor
_destroy_user
null
def _destroy_user(self, nickname, channel=None, monitor_override=False): # Override _destroy_user to not remove user if they are being monitored by us. if channel: channels = [self.channels[channel]] else: channels = self.channels.values() for ch in channels: # Remove from nicklist. ch['users'].discard(nickname) # Remove from statuses. for status in self._nickname_prefixes.values(): if status in ch['modes'] and nickname in ch['modes'][status]: ch['modes'][status].remove(nickname) # If we're not in any common channels with the user anymore, we have no reliable way to keep their info up-to-date. # Remove the user. if (monitor_override or not self.is_monitoring(nickname)) and (not channel or not any(nickname in ch['users'] for ch in self.channels.values())): del self.users[nickname]
(self, nickname, channel=None, monitor_override=False)
42,321
pydle.features.rfc1459.client
_format_host_range
null
def _format_host_range(self, host, range, allow_everything=False): # IPv4? try: addr = ipaddress.IPv4Network(host, strict=False) max = 4 if allow_everything else 3 # Round up subnet to nearest octet. subnet = addr.prefixlen + (8 - addr.prefixlen % 8) # Remove range mask. subnet -= min(range, max) * 8 rangeaddr = addr.supernet(new_prefix=subnet).exploded.split('/', 1)[0] return rangeaddr.replace('0', '*') except ValueError: pass # IPv6? try: addr = ipaddress.IPv6Network(host, strict=False) max = 4 if allow_everything else 3 # Round up subnet to nearest 32-et. subnet = addr.prefixlen + (32 - addr.prefixlen % 32) # Remove range mask. subnet -= min(range, max) * 32 rangeaddr = addr.supernet(new_prefix=subnet).exploded.split('/', 1)[0] return rangeaddr.replace(':0000', ':*') except ValueError: pass # Host? if '.' in host: # Split pieces. pieces = host.split('.') max = len(pieces) if not allow_everything: max -= 1 # Figure out how many to mask. to_mask = min(range, max) # Mask pieces. pieces[:to_mask] = '*' * to_mask return '.'.join(pieces) # Wat. if allow_everything and range >= 4: return '*' return host
(self, host, range, allow_everything=False)
42,323
pydle.features.rfc1459.client
_has_message
Whether or not we have messages available for processing.
def _has_message(self): """ Whether or not we have messages available for processing. """ sep = protocol.MINIMAL_LINE_SEPARATOR.encode(self.encoding) return sep in self._receive_buffer
(self)
42,325
pydle.features.rfc1459.client
_parse_channel_modes
null
def _parse_channel_modes(self, channel, modes, current=None): if current is None: current = self.channels[channel]['modes'] return parsing.parse_modes(modes, current, behaviour=self._channel_modes_behaviour)
(self, channel, modes, current=None)
42,326
pydle.features.ircv3.tags
_parse_message
null
def _parse_message(self): sep = rfc1459.protocol.MINIMAL_LINE_SEPARATOR.encode(self.encoding) message, _, data = self._receive_buffer.partition(sep) self._receive_buffer = data return TaggedMessage.parse(message + sep, encoding=self.encoding)
(self)
42,327
pydle.features.rfc1459.client
_parse_user
null
def _parse_user(self, data): if data: nickname, username, host = parsing.parse_user(data) metadata = {'nickname': nickname} if username: metadata['username'] = username if host: metadata['hostname'] = host else: return None, {} return nickname, metadata
(self, data)
42,328
pydle.features.rfc1459.client
_parse_user_modes
null
def _parse_user_modes(self, user, modes, current=None): if current is None: current = self.users[user]['modes'] return parsing.parse_modes(modes, current, behaviour=self._user_modes_behaviour)
(self, user, modes, current=None)
42,330
pydle.features.ircv3.cap
_register
Hijack registration to send a CAP LS first.
def _reset_attributes(self): super()._reset_attributes() self._capabilities = {} self._capabilities_requested = set() self._capabilities_negotiating = set()
(self)
42,331
pydle.features.rfc1459.client
_registration_completed
We're connected and registered. Receive proper nickname and emit fake NICK message.
def _format_host_range(self, host, range, allow_everything=False): # IPv4? try: addr = ipaddress.IPv4Network(host, strict=False) max = 4 if allow_everything else 3 # Round up subnet to nearest octet. subnet = addr.prefixlen + (8 - addr.prefixlen % 8) # Remove range mask. subnet -= min(range, max) * 8 rangeaddr = addr.supernet(new_prefix=subnet).exploded.split('/', 1)[0] return rangeaddr.replace('0', '*') except ValueError: pass # IPv6? try: addr = ipaddress.IPv6Network(host, strict=False) max = 4 if allow_everything else 3 # Round up subnet to nearest 32-et. subnet = addr.prefixlen + (32 - addr.prefixlen % 32) # Remove range mask. subnet -= min(range, max) * 32 rangeaddr = addr.supernet(new_prefix=subnet).exploded.split('/', 1)[0] return rangeaddr.replace(':0000', ':*') except ValueError: pass # Host? if '.' in host: # Split pieces. pieces = host.split('.') max = len(pieces) if not allow_everything: max -= 1 # Figure out how many to mask. to_mask = min(range, max) # Mask pieces. pieces[:to_mask] = '*' * to_mask return '.'.join(pieces) # Wat. if allow_everything and range >= 4: return '*' return host
(self, message)
42,332
pydle.features.ircv3.ircv3_1
_rename_user
null
## ircv3_1.py # IRCv3.1 full spec support. from pydle.features import account, tls from . import cap from . import sasl __all__ = ['IRCv3_1Support'] NO_ACCOUNT = '*' class IRCv3_1Support(sasl.SASLSupport, cap.CapabilityNegotiationSupport, account.AccountSupport, tls.TLSSupport): """ Support for IRCv3.1's base and optional extensions. """ async def _rename_user(self, user, new): # If the server supports account-notify, we will be told about the registration status changing. # As such, we can skip the song and dance pydle.features.account does. if self._capabilities.get('account-notify', False): account = self.users.get(user, {}).get('account', None) identified = self.users.get(user, {}).get('identified', False) await super()._rename_user(user, new) if self._capabilities.get('account-notify', False): await self._sync_user(new, {'account': account, 'identified': identified}) ## IRC callbacks. async def on_capability_account_notify_available(self, value): """ Take note of user account changes. """ return True async def on_capability_away_notify_available(self, value): """ Take note of AWAY messages. """ return True async def on_capability_extended_join_available(self, value): """ Take note of user account and realname on JOIN. """ return True async def on_capability_multi_prefix_available(self, value): """ Thanks to how underlying client code works we already support multiple prefixes. """ return True async def on_capability_tls_available(self, value): """ We never need to request this explicitly. """ return False ## Message handlers. async def on_raw_account(self, message): """ Changes in the associated account for a nickname. """ if not self._capabilities.get('account-notify', False): return nick, metadata = self._parse_user(message.source) account = message.params[0] if nick not in self.users: return await self._sync_user(nick, metadata) if account == NO_ACCOUNT: await self._sync_user(nick, {'account': None, 'identified': False}) else: await self._sync_user(nick, {'account': account, 'identified': True}) async def on_raw_away(self, message): """ Process AWAY messages. """ if 'away-notify' not in self._capabilities or not self._capabilities['away-notify']: return nick, metadata = self._parse_user(message.source) if nick not in self.users: return await self._sync_user(nick, metadata) self.users[nick]['away'] = len(message.params) > 0 self.users[nick]['away_message'] = message.params[0] if len(message.params) > 0 else None async def on_raw_join(self, message): """ Process extended JOIN messages. """ if 'extended-join' in self._capabilities and self._capabilities['extended-join']: nick, metadata = self._parse_user(message.source) channels, account, realname = message.params await self._sync_user(nick, metadata) # Emit a fake join message. fakemsg = self._create_message('JOIN', channels, source=message.source) await super().on_raw_join(fakemsg) if account == NO_ACCOUNT: account = None self.users[nick]['account'] = account self.users[nick]['realname'] = realname else: await super().on_raw_join(message)
(self, user, new)
42,333
pydle.features.ircv3.metadata
_reset_attributes
null
def _reset_attributes(self): super()._reset_attributes() self._pending['metadata'] = {} self._metadata_info = {} self._metadata_queue = []
(self)
42,334
pydle.features.rfc1459.client
_reset_connection_attributes
null
def _reset_connection_attributes(self): super()._reset_connection_attributes() self.password = None
(self)
42,335
pydle.features.ircv3.sasl
_sasl_abort
Abort SASL authentication.
def _reset_attributes(self): super()._reset_attributes() self._sasl_client = None self._sasl_timer = None self._sasl_challenge = b'' self._sasl_mechanisms = None
(self, timeout=False)
42,336
pydle.features.ircv3.sasl
_sasl_end
Finalize SASL authentication.
def _reset_attributes(self): super()._reset_attributes() self._sasl_client = None self._sasl_timer = None self._sasl_challenge = b'' self._sasl_mechanisms = None
(self)
42,337
pydle.features.ircv3.sasl
_sasl_respond
Respond to SASL challenge with response.
def _reset_attributes(self): super()._reset_attributes() self._sasl_client = None self._sasl_timer = None self._sasl_challenge = b'' self._sasl_mechanisms = None
(self)
42,338
pydle.features.ircv3.sasl
_sasl_start
Initiate SASL authentication.
def _reset_attributes(self): super()._reset_attributes() self._sasl_client = None self._sasl_timer = None self._sasl_challenge = b'' self._sasl_mechanisms = None
(self, mechanism)
42,341
pydle.features.rfc1459.client
away
Mark self as away.
def _parse_message(self): sep = protocol.MINIMAL_LINE_SEPARATOR.encode(self.encoding) message, _, data = self._receive_buffer.partition(sep) self._receive_buffer = data return parsing.RFC1459Message.parse(message + sep, encoding=self.encoding)
(self, message)
42,342
pydle.features.rfc1459.client
back
Mark self as not away.
def _parse_message(self): sep = protocol.MINIMAL_LINE_SEPARATOR.encode(self.encoding) message, _, data = self._receive_buffer.partition(sep) self._receive_buffer = data return parsing.RFC1459Message.parse(message + sep, encoding=self.encoding)
(self)
42,343
pydle.features.rfc1459.client
ban
Ban user from channel. Target can be either a user or a host. This command will not kick: use kickban() for that. range indicates the IP/host range to ban: 0 means ban only the IP/host, 1+ means ban that many 'degrees' (up to 3 for IP addresses) of the host for range bans.
def _parse_message(self): sep = protocol.MINIMAL_LINE_SEPARATOR.encode(self.encoding) message, _, data = self._receive_buffer.partition(sep) self._receive_buffer = data return parsing.RFC1459Message.parse(message + sep, encoding=self.encoding)
(self, channel, target, range=0)
42,345
pydle.features.tls
connect
Connect to a server, optionally over TLS. See pydle.features.RFC1459Support.connect for misc parameters.
def __init__(self, *args, tls_client_cert=None, tls_client_cert_key=None, tls_client_cert_password=None, **kwargs): super().__init__(*args, **kwargs) self.tls_client_cert = tls_client_cert self.tls_client_cert_key = tls_client_cert_key self.tls_client_cert_password = tls_client_cert_password
(self, hostname=None, port=None, tls=False, **kwargs)
42,346
pydle.features.ctcp
ctcp
Send a CTCP request to a target.
## ctcp.py # Client-to-Client-Protocol (CTCP) support. import pydle import pydle.protocol from pydle.features import rfc1459 from pydle import client __all__ = ['CTCPSupport'] CTCP_DELIMITER = '\x01' CTCP_ESCAPE_CHAR = '\x16' class CTCPSupport(rfc1459.RFC1459Support): """ Support for CTCP messages. """ ## Callbacks. async def on_ctcp(self, by, target, what, contents): """ Callback called when the user received a CTCP message. Client subclasses can override on_ctcp_<type> to be called when receiving a message of that specific CTCP type, in addition to this callback. """ ... async def on_ctcp_reply(self, by, target, what, response): """ Callback called when the user received a CTCP response. Client subclasses can override on_ctcp_<type>_reply to be called when receiving a reply of that specific CTCP type, in addition to this callback. """ ... async def on_ctcp_version(self, by, target, contents): """ Built-in CTCP version as some networks seem to require it. """ version = '{name} v{ver}'.format(name=pydle.__name__, ver=pydle.__version__) await self.ctcp_reply(by, 'VERSION', version) ## IRC API. async def ctcp(self, target, query, contents=None): """ Send a CTCP request to a target. """ if self.is_channel(target) and not self.in_channel(target): raise client.NotInChannel(target) await self.message(target, construct_ctcp(query, contents)) async def ctcp_reply(self, target, query, response): """ Send a CTCP reply to a target. """ if self.is_channel(target) and not self.in_channel(target): raise client.NotInChannel(target) await self.notice(target, construct_ctcp(query, response)) ## Handler overrides. async def on_raw_privmsg(self, message): """ Modify PRIVMSG to redirect CTCP messages. """ nick, metadata = self._parse_user(message.source) target, msg = message.params if is_ctcp(msg): await self._sync_user(nick, metadata) type, contents = parse_ctcp(msg) # Find dedicated handler if it exists. attr = 'on_ctcp_' + pydle.protocol.identifierify(type) if hasattr(self, attr): await getattr(self, attr)(nick, target, contents) # Invoke global handler. await self.on_ctcp(nick, target, type, contents) else: await super().on_raw_privmsg(message) async def on_raw_notice(self, message): """ Modify NOTICE to redirect CTCP messages. """ nick, metadata = self._parse_user(message.source) target, msg = message.params if is_ctcp(msg): await self._sync_user(nick, metadata) _type, response = parse_ctcp(msg) # Find dedicated handler if it exists. attr = 'on_ctcp_' + pydle.protocol.identifierify(_type) + '_reply' if hasattr(self, attr): await getattr(self, attr)(nick, target, response) # Invoke global handler. await self.on_ctcp_reply(nick, target, _type, response) else: await super().on_raw_notice(message)
(self, target, query, contents=None)
42,347
pydle.features.ctcp
ctcp_reply
Send a CTCP reply to a target.
## ctcp.py # Client-to-Client-Protocol (CTCP) support. import pydle import pydle.protocol from pydle.features import rfc1459 from pydle import client __all__ = ['CTCPSupport'] CTCP_DELIMITER = '\x01' CTCP_ESCAPE_CHAR = '\x16' class CTCPSupport(rfc1459.RFC1459Support): """ Support for CTCP messages. """ ## Callbacks. async def on_ctcp(self, by, target, what, contents): """ Callback called when the user received a CTCP message. Client subclasses can override on_ctcp_<type> to be called when receiving a message of that specific CTCP type, in addition to this callback. """ ... async def on_ctcp_reply(self, by, target, what, response): """ Callback called when the user received a CTCP response. Client subclasses can override on_ctcp_<type>_reply to be called when receiving a reply of that specific CTCP type, in addition to this callback. """ ... async def on_ctcp_version(self, by, target, contents): """ Built-in CTCP version as some networks seem to require it. """ version = '{name} v{ver}'.format(name=pydle.__name__, ver=pydle.__version__) await self.ctcp_reply(by, 'VERSION', version) ## IRC API. async def ctcp(self, target, query, contents=None): """ Send a CTCP request to a target. """ if self.is_channel(target) and not self.in_channel(target): raise client.NotInChannel(target) await self.message(target, construct_ctcp(query, contents)) async def ctcp_reply(self, target, query, response): """ Send a CTCP reply to a target. """ if self.is_channel(target) and not self.in_channel(target): raise client.NotInChannel(target) await self.notice(target, construct_ctcp(query, response)) ## Handler overrides. async def on_raw_privmsg(self, message): """ Modify PRIVMSG to redirect CTCP messages. """ nick, metadata = self._parse_user(message.source) target, msg = message.params if is_ctcp(msg): await self._sync_user(nick, metadata) type, contents = parse_ctcp(msg) # Find dedicated handler if it exists. attr = 'on_ctcp_' + pydle.protocol.identifierify(type) if hasattr(self, attr): await getattr(self, attr)(nick, target, contents) # Invoke global handler. await self.on_ctcp(nick, target, type, contents) else: await super().on_raw_privmsg(message) async def on_raw_notice(self, message): """ Modify NOTICE to redirect CTCP messages. """ nick, metadata = self._parse_user(message.source) target, msg = message.params if is_ctcp(msg): await self._sync_user(nick, metadata) _type, response = parse_ctcp(msg) # Find dedicated handler if it exists. attr = 'on_ctcp_' + pydle.protocol.identifierify(_type) + '_reply' if hasattr(self, attr): await getattr(self, attr)(nick, target, response) # Invoke global handler. await self.on_ctcp_reply(nick, target, _type, response) else: await super().on_raw_notice(message)
(self, target, query, response)
42,348
pydle.features.rfc1459.client
cycle
Rejoin channel.
def _parse_message(self): sep = protocol.MINIMAL_LINE_SEPARATOR.encode(self.encoding) message, _, data = self._receive_buffer.partition(sep) self._receive_buffer = data return parsing.RFC1459Message.parse(message + sep, encoding=self.encoding)
(self, channel)
42,351
pydle.features.ircv3.metadata
get_metadata
Return user metadata information. This is a blocking asynchronous method: it has to be called from a coroutine, as follows: metadata = await self.get_metadata('#foo')
def _reset_attributes(self): super()._reset_attributes() self._pending['metadata'] = {} self._metadata_info = {} self._metadata_queue = []
(self, target)
42,354
pydle.features.rfc1459.client
is_channel
null
def is_channel(self, chan): return any(chan.startswith(prefix) for prefix in self._channel_prefixes)
(self, chan)
42,355
pydle.features.ircv3.monitor
is_monitoring
Return whether or not we are monitoring the target's online status.
def is_monitoring(self, target): """ Return whether or not we are monitoring the target's online status. """ return target in self._monitoring
(self, target)
42,356
pydle.features.rfc1459.client
is_same_channel
Check if given nicknames are equal in the server's case mapping.
def is_same_channel(self, left, right): """ Check if given nicknames are equal in the server's case mapping. """ return self.normalize(left) == self.normalize(right)
(self, left, right)
42,357
pydle.features.rfc1459.client
is_same_nick
Check if given nicknames are equal in the server's case mapping.
def is_same_nick(self, left, right): """ Check if given nicknames are equal in the server's case mapping. """ return self.normalize(left) == self.normalize(right)
(self, left, right)
42,358
pydle.features.rfc1459.client
join
Join channel, optionally with password.
def _parse_message(self): sep = protocol.MINIMAL_LINE_SEPARATOR.encode(self.encoding) message, _, data = self._receive_buffer.partition(sep) self._receive_buffer = data return parsing.RFC1459Message.parse(message + sep, encoding=self.encoding)
(self, channel, password=None)
42,359
pydle.features.rfc1459.client
kick
Kick user from channel.
def _parse_message(self): sep = protocol.MINIMAL_LINE_SEPARATOR.encode(self.encoding) message, _, data = self._receive_buffer.partition(sep) self._receive_buffer = data return parsing.RFC1459Message.parse(message + sep, encoding=self.encoding)
(self, channel, target, reason=None)
42,360
pydle.features.rfc1459.client
kickban
Kick and ban user from channel.
def _parse_message(self): sep = protocol.MINIMAL_LINE_SEPARATOR.encode(self.encoding) message, _, data = self._receive_buffer.partition(sep) self._receive_buffer = data return parsing.RFC1459Message.parse(message + sep, encoding=self.encoding)
(self, channel, target, reason=None, range=0)
42,361
pydle.features.ircv3.ircv3_2
message
null
## ircv3_2.py # IRCv3.2 support (in progress). from . import ircv3_1 from . import tags from . import monitor from . import metadata __all__ = ['IRCv3_2Support'] class IRCv3_2Support(metadata.MetadataSupport, monitor.MonitoringSupport, tags.TaggedMessageSupport, ircv3_1.IRCv3_1Support): """ Support for some of IRCv3.2's extensions. """ ## IRC callbacks. async def on_capability_account_tag_available(self, value): """ Add an account message tag to user messages. """ return True async def on_capability_cap_notify_available(self, value): """ Take note of new or removed capabilities. """ return True async def on_capability_chghost_available(self, value): """ Server reply to indicate a user we are in a common channel with changed user and/or host. """ return True async def on_capability_echo_message_available(self, value): """ Echo PRIVMSG and NOTICEs back to client. """ return True async def on_capability_invite_notify_available(self, value): """ Broadcast invite messages to certain other clients. """ return True async def on_capability_userhost_in_names_available(self, value): """ Show full user!nick@host in NAMES list. We already parse it like that. """ return True async def on_capability_uhnames_available(self, value): """ Possibly outdated alias for userhost-in-names. """ return await self.on_capability_userhost_in_names_available(value) async def on_isupport_uhnames(self, value): """ Let the server know that we support UHNAMES using the old ISUPPORT method, for legacy support. """ await self.rawmsg('PROTOCTL', 'UHNAMES') ## API overrides. async def message(self, target, message): await super().message(target, message) if not self._capabilities.get('echo-message'): await self.on_message(target, self.nickname, message) if self.is_channel(target): await self.on_channel_message(target, self.nickname, message) else: await self.on_private_message(target, self.nickname, message) async def notice(self, target, message): await super().notice(target, message) if not self._capabilities.get('echo-message'): await self.on_notice(target, self.nickname, message) if self.is_channel(target): await self.on_channel_notice(target, self.nickname, message) else: await self.on_private_notice(target, self.nickname, message) ## Message handlers. async def on_raw(self, message): if 'account' in message.tags: nick, _ = self._parse_user(message.source) if nick in self.users: metadata = { 'identified': True, 'account': message.tags['account'] } await self._sync_user(nick, metadata) await super().on_raw(message) async def on_raw_chghost(self, message): """ Change user and/or host of user. """ if 'chghost' not in self._capabilities or not self._capabilities['chghost']: return nick, _ = self._parse_user(message.source) if nick not in self.users: return # Update user and host. metadata = { 'username': message.params[0], 'hostname': message.params[1] } await self._sync_user(nick, metadata)
(self, target, message)
42,362
pydle.features.ircv3.monitor
monitor
Start monitoring the online status of a user. Returns whether or not the server supports monitoring.
def _destroy_user(self, nickname, channel=None, monitor_override=False): # Override _destroy_user to not remove user if they are being monitored by us. if channel: channels = [self.channels[channel]] else: channels = self.channels.values() for ch in channels: # Remove from nicklist. ch['users'].discard(nickname) # Remove from statuses. for status in self._nickname_prefixes.values(): if status in ch['modes'] and nickname in ch['modes'][status]: ch['modes'][status].remove(nickname) # If we're not in any common channels with the user anymore, we have no reliable way to keep their info up-to-date. # Remove the user. if (monitor_override or not self.is_monitoring(nickname)) and (not channel or not any(nickname in ch['users'] for ch in self.channels.values())): del self.users[nickname]
(self, target)
42,363
pydle.features.rfc1459.client
normalize
null
def normalize(self, input): return parsing.normalize(input, case_mapping=self._case_mapping)
(self, input)
42,365
pydle.features.ircv3.ircv3_1
on_capability_account_notify_available
Take note of user account changes.
## ircv3_1.py # IRCv3.1 full spec support. from pydle.features import account, tls from . import cap from . import sasl __all__ = ['IRCv3_1Support'] NO_ACCOUNT = '*' class IRCv3_1Support(sasl.SASLSupport, cap.CapabilityNegotiationSupport, account.AccountSupport, tls.TLSSupport): """ Support for IRCv3.1's base and optional extensions. """ async def _rename_user(self, user, new): # If the server supports account-notify, we will be told about the registration status changing. # As such, we can skip the song and dance pydle.features.account does. if self._capabilities.get('account-notify', False): account = self.users.get(user, {}).get('account', None) identified = self.users.get(user, {}).get('identified', False) await super()._rename_user(user, new) if self._capabilities.get('account-notify', False): await self._sync_user(new, {'account': account, 'identified': identified}) ## IRC callbacks. async def on_capability_account_notify_available(self, value): """ Take note of user account changes. """ return True async def on_capability_away_notify_available(self, value): """ Take note of AWAY messages. """ return True async def on_capability_extended_join_available(self, value): """ Take note of user account and realname on JOIN. """ return True async def on_capability_multi_prefix_available(self, value): """ Thanks to how underlying client code works we already support multiple prefixes. """ return True async def on_capability_tls_available(self, value): """ We never need to request this explicitly. """ return False ## Message handlers. async def on_raw_account(self, message): """ Changes in the associated account for a nickname. """ if not self._capabilities.get('account-notify', False): return nick, metadata = self._parse_user(message.source) account = message.params[0] if nick not in self.users: return await self._sync_user(nick, metadata) if account == NO_ACCOUNT: await self._sync_user(nick, {'account': None, 'identified': False}) else: await self._sync_user(nick, {'account': account, 'identified': True}) async def on_raw_away(self, message): """ Process AWAY messages. """ if 'away-notify' not in self._capabilities or not self._capabilities['away-notify']: return nick, metadata = self._parse_user(message.source) if nick not in self.users: return await self._sync_user(nick, metadata) self.users[nick]['away'] = len(message.params) > 0 self.users[nick]['away_message'] = message.params[0] if len(message.params) > 0 else None async def on_raw_join(self, message): """ Process extended JOIN messages. """ if 'extended-join' in self._capabilities and self._capabilities['extended-join']: nick, metadata = self._parse_user(message.source) channels, account, realname = message.params await self._sync_user(nick, metadata) # Emit a fake join message. fakemsg = self._create_message('JOIN', channels, source=message.source) await super().on_raw_join(fakemsg) if account == NO_ACCOUNT: account = None self.users[nick]['account'] = account self.users[nick]['realname'] = realname else: await super().on_raw_join(message)
(self, value)
42,366
pydle.features.ircv3.ircv3_2
on_capability_account_tag_available
Add an account message tag to user messages.
## ircv3_2.py # IRCv3.2 support (in progress). from . import ircv3_1 from . import tags from . import monitor from . import metadata __all__ = ['IRCv3_2Support'] class IRCv3_2Support(metadata.MetadataSupport, monitor.MonitoringSupport, tags.TaggedMessageSupport, ircv3_1.IRCv3_1Support): """ Support for some of IRCv3.2's extensions. """ ## IRC callbacks. async def on_capability_account_tag_available(self, value): """ Add an account message tag to user messages. """ return True async def on_capability_cap_notify_available(self, value): """ Take note of new or removed capabilities. """ return True async def on_capability_chghost_available(self, value): """ Server reply to indicate a user we are in a common channel with changed user and/or host. """ return True async def on_capability_echo_message_available(self, value): """ Echo PRIVMSG and NOTICEs back to client. """ return True async def on_capability_invite_notify_available(self, value): """ Broadcast invite messages to certain other clients. """ return True async def on_capability_userhost_in_names_available(self, value): """ Show full user!nick@host in NAMES list. We already parse it like that. """ return True async def on_capability_uhnames_available(self, value): """ Possibly outdated alias for userhost-in-names. """ return await self.on_capability_userhost_in_names_available(value) async def on_isupport_uhnames(self, value): """ Let the server know that we support UHNAMES using the old ISUPPORT method, for legacy support. """ await self.rawmsg('PROTOCTL', 'UHNAMES') ## API overrides. async def message(self, target, message): await super().message(target, message) if not self._capabilities.get('echo-message'): await self.on_message(target, self.nickname, message) if self.is_channel(target): await self.on_channel_message(target, self.nickname, message) else: await self.on_private_message(target, self.nickname, message) async def notice(self, target, message): await super().notice(target, message) if not self._capabilities.get('echo-message'): await self.on_notice(target, self.nickname, message) if self.is_channel(target): await self.on_channel_notice(target, self.nickname, message) else: await self.on_private_notice(target, self.nickname, message) ## Message handlers. async def on_raw(self, message): if 'account' in message.tags: nick, _ = self._parse_user(message.source) if nick in self.users: metadata = { 'identified': True, 'account': message.tags['account'] } await self._sync_user(nick, metadata) await super().on_raw(message) async def on_raw_chghost(self, message): """ Change user and/or host of user. """ if 'chghost' not in self._capabilities or not self._capabilities['chghost']: return nick, _ = self._parse_user(message.source) if nick not in self.users: return # Update user and host. metadata = { 'username': message.params[0], 'hostname': message.params[1] } await self._sync_user(nick, metadata)
(self, value)
42,367
pydle.features.ircv3.ircv3_1
on_capability_away_notify_available
Take note of AWAY messages.
## ircv3_1.py # IRCv3.1 full spec support. from pydle.features import account, tls from . import cap from . import sasl __all__ = ['IRCv3_1Support'] NO_ACCOUNT = '*' class IRCv3_1Support(sasl.SASLSupport, cap.CapabilityNegotiationSupport, account.AccountSupport, tls.TLSSupport): """ Support for IRCv3.1's base and optional extensions. """ async def _rename_user(self, user, new): # If the server supports account-notify, we will be told about the registration status changing. # As such, we can skip the song and dance pydle.features.account does. if self._capabilities.get('account-notify', False): account = self.users.get(user, {}).get('account', None) identified = self.users.get(user, {}).get('identified', False) await super()._rename_user(user, new) if self._capabilities.get('account-notify', False): await self._sync_user(new, {'account': account, 'identified': identified}) ## IRC callbacks. async def on_capability_account_notify_available(self, value): """ Take note of user account changes. """ return True async def on_capability_away_notify_available(self, value): """ Take note of AWAY messages. """ return True async def on_capability_extended_join_available(self, value): """ Take note of user account and realname on JOIN. """ return True async def on_capability_multi_prefix_available(self, value): """ Thanks to how underlying client code works we already support multiple prefixes. """ return True async def on_capability_tls_available(self, value): """ We never need to request this explicitly. """ return False ## Message handlers. async def on_raw_account(self, message): """ Changes in the associated account for a nickname. """ if not self._capabilities.get('account-notify', False): return nick, metadata = self._parse_user(message.source) account = message.params[0] if nick not in self.users: return await self._sync_user(nick, metadata) if account == NO_ACCOUNT: await self._sync_user(nick, {'account': None, 'identified': False}) else: await self._sync_user(nick, {'account': account, 'identified': True}) async def on_raw_away(self, message): """ Process AWAY messages. """ if 'away-notify' not in self._capabilities or not self._capabilities['away-notify']: return nick, metadata = self._parse_user(message.source) if nick not in self.users: return await self._sync_user(nick, metadata) self.users[nick]['away'] = len(message.params) > 0 self.users[nick]['away_message'] = message.params[0] if len(message.params) > 0 else None async def on_raw_join(self, message): """ Process extended JOIN messages. """ if 'extended-join' in self._capabilities and self._capabilities['extended-join']: nick, metadata = self._parse_user(message.source) channels, account, realname = message.params await self._sync_user(nick, metadata) # Emit a fake join message. fakemsg = self._create_message('JOIN', channels, source=message.source) await super().on_raw_join(fakemsg) if account == NO_ACCOUNT: account = None self.users[nick]['account'] = account self.users[nick]['realname'] = realname else: await super().on_raw_join(message)
(self, value)
42,368
pydle.features.ircv3.ircv3_2
on_capability_cap_notify_available
Take note of new or removed capabilities.
## ircv3_2.py # IRCv3.2 support (in progress). from . import ircv3_1 from . import tags from . import monitor from . import metadata __all__ = ['IRCv3_2Support'] class IRCv3_2Support(metadata.MetadataSupport, monitor.MonitoringSupport, tags.TaggedMessageSupport, ircv3_1.IRCv3_1Support): """ Support for some of IRCv3.2's extensions. """ ## IRC callbacks. async def on_capability_account_tag_available(self, value): """ Add an account message tag to user messages. """ return True async def on_capability_cap_notify_available(self, value): """ Take note of new or removed capabilities. """ return True async def on_capability_chghost_available(self, value): """ Server reply to indicate a user we are in a common channel with changed user and/or host. """ return True async def on_capability_echo_message_available(self, value): """ Echo PRIVMSG and NOTICEs back to client. """ return True async def on_capability_invite_notify_available(self, value): """ Broadcast invite messages to certain other clients. """ return True async def on_capability_userhost_in_names_available(self, value): """ Show full user!nick@host in NAMES list. We already parse it like that. """ return True async def on_capability_uhnames_available(self, value): """ Possibly outdated alias for userhost-in-names. """ return await self.on_capability_userhost_in_names_available(value) async def on_isupport_uhnames(self, value): """ Let the server know that we support UHNAMES using the old ISUPPORT method, for legacy support. """ await self.rawmsg('PROTOCTL', 'UHNAMES') ## API overrides. async def message(self, target, message): await super().message(target, message) if not self._capabilities.get('echo-message'): await self.on_message(target, self.nickname, message) if self.is_channel(target): await self.on_channel_message(target, self.nickname, message) else: await self.on_private_message(target, self.nickname, message) async def notice(self, target, message): await super().notice(target, message) if not self._capabilities.get('echo-message'): await self.on_notice(target, self.nickname, message) if self.is_channel(target): await self.on_channel_notice(target, self.nickname, message) else: await self.on_private_notice(target, self.nickname, message) ## Message handlers. async def on_raw(self, message): if 'account' in message.tags: nick, _ = self._parse_user(message.source) if nick in self.users: metadata = { 'identified': True, 'account': message.tags['account'] } await self._sync_user(nick, metadata) await super().on_raw(message) async def on_raw_chghost(self, message): """ Change user and/or host of user. """ if 'chghost' not in self._capabilities or not self._capabilities['chghost']: return nick, _ = self._parse_user(message.source) if nick not in self.users: return # Update user and host. metadata = { 'username': message.params[0], 'hostname': message.params[1] } await self._sync_user(nick, metadata)
(self, value)
42,369
pydle.features.ircv3.ircv3_2
on_capability_chghost_available
Server reply to indicate a user we are in a common channel with changed user and/or host.
## ircv3_2.py # IRCv3.2 support (in progress). from . import ircv3_1 from . import tags from . import monitor from . import metadata __all__ = ['IRCv3_2Support'] class IRCv3_2Support(metadata.MetadataSupport, monitor.MonitoringSupport, tags.TaggedMessageSupport, ircv3_1.IRCv3_1Support): """ Support for some of IRCv3.2's extensions. """ ## IRC callbacks. async def on_capability_account_tag_available(self, value): """ Add an account message tag to user messages. """ return True async def on_capability_cap_notify_available(self, value): """ Take note of new or removed capabilities. """ return True async def on_capability_chghost_available(self, value): """ Server reply to indicate a user we are in a common channel with changed user and/or host. """ return True async def on_capability_echo_message_available(self, value): """ Echo PRIVMSG and NOTICEs back to client. """ return True async def on_capability_invite_notify_available(self, value): """ Broadcast invite messages to certain other clients. """ return True async def on_capability_userhost_in_names_available(self, value): """ Show full user!nick@host in NAMES list. We already parse it like that. """ return True async def on_capability_uhnames_available(self, value): """ Possibly outdated alias for userhost-in-names. """ return await self.on_capability_userhost_in_names_available(value) async def on_isupport_uhnames(self, value): """ Let the server know that we support UHNAMES using the old ISUPPORT method, for legacy support. """ await self.rawmsg('PROTOCTL', 'UHNAMES') ## API overrides. async def message(self, target, message): await super().message(target, message) if not self._capabilities.get('echo-message'): await self.on_message(target, self.nickname, message) if self.is_channel(target): await self.on_channel_message(target, self.nickname, message) else: await self.on_private_message(target, self.nickname, message) async def notice(self, target, message): await super().notice(target, message) if not self._capabilities.get('echo-message'): await self.on_notice(target, self.nickname, message) if self.is_channel(target): await self.on_channel_notice(target, self.nickname, message) else: await self.on_private_notice(target, self.nickname, message) ## Message handlers. async def on_raw(self, message): if 'account' in message.tags: nick, _ = self._parse_user(message.source) if nick in self.users: metadata = { 'identified': True, 'account': message.tags['account'] } await self._sync_user(nick, metadata) await super().on_raw(message) async def on_raw_chghost(self, message): """ Change user and/or host of user. """ if 'chghost' not in self._capabilities or not self._capabilities['chghost']: return nick, _ = self._parse_user(message.source) if nick not in self.users: return # Update user and host. metadata = { 'username': message.params[0], 'hostname': message.params[1] } await self._sync_user(nick, metadata)
(self, value)
42,370
pydle.features.ircv3.ircv3_2
on_capability_echo_message_available
Echo PRIVMSG and NOTICEs back to client.
## ircv3_2.py # IRCv3.2 support (in progress). from . import ircv3_1 from . import tags from . import monitor from . import metadata __all__ = ['IRCv3_2Support'] class IRCv3_2Support(metadata.MetadataSupport, monitor.MonitoringSupport, tags.TaggedMessageSupport, ircv3_1.IRCv3_1Support): """ Support for some of IRCv3.2's extensions. """ ## IRC callbacks. async def on_capability_account_tag_available(self, value): """ Add an account message tag to user messages. """ return True async def on_capability_cap_notify_available(self, value): """ Take note of new or removed capabilities. """ return True async def on_capability_chghost_available(self, value): """ Server reply to indicate a user we are in a common channel with changed user and/or host. """ return True async def on_capability_echo_message_available(self, value): """ Echo PRIVMSG and NOTICEs back to client. """ return True async def on_capability_invite_notify_available(self, value): """ Broadcast invite messages to certain other clients. """ return True async def on_capability_userhost_in_names_available(self, value): """ Show full user!nick@host in NAMES list. We already parse it like that. """ return True async def on_capability_uhnames_available(self, value): """ Possibly outdated alias for userhost-in-names. """ return await self.on_capability_userhost_in_names_available(value) async def on_isupport_uhnames(self, value): """ Let the server know that we support UHNAMES using the old ISUPPORT method, for legacy support. """ await self.rawmsg('PROTOCTL', 'UHNAMES') ## API overrides. async def message(self, target, message): await super().message(target, message) if not self._capabilities.get('echo-message'): await self.on_message(target, self.nickname, message) if self.is_channel(target): await self.on_channel_message(target, self.nickname, message) else: await self.on_private_message(target, self.nickname, message) async def notice(self, target, message): await super().notice(target, message) if not self._capabilities.get('echo-message'): await self.on_notice(target, self.nickname, message) if self.is_channel(target): await self.on_channel_notice(target, self.nickname, message) else: await self.on_private_notice(target, self.nickname, message) ## Message handlers. async def on_raw(self, message): if 'account' in message.tags: nick, _ = self._parse_user(message.source) if nick in self.users: metadata = { 'identified': True, 'account': message.tags['account'] } await self._sync_user(nick, metadata) await super().on_raw(message) async def on_raw_chghost(self, message): """ Change user and/or host of user. """ if 'chghost' not in self._capabilities or not self._capabilities['chghost']: return nick, _ = self._parse_user(message.source) if nick not in self.users: return # Update user and host. metadata = { 'username': message.params[0], 'hostname': message.params[1] } await self._sync_user(nick, metadata)
(self, value)
42,371
pydle.features.ircv3.ircv3_1
on_capability_extended_join_available
Take note of user account and realname on JOIN.
## ircv3_1.py # IRCv3.1 full spec support. from pydle.features import account, tls from . import cap from . import sasl __all__ = ['IRCv3_1Support'] NO_ACCOUNT = '*' class IRCv3_1Support(sasl.SASLSupport, cap.CapabilityNegotiationSupport, account.AccountSupport, tls.TLSSupport): """ Support for IRCv3.1's base and optional extensions. """ async def _rename_user(self, user, new): # If the server supports account-notify, we will be told about the registration status changing. # As such, we can skip the song and dance pydle.features.account does. if self._capabilities.get('account-notify', False): account = self.users.get(user, {}).get('account', None) identified = self.users.get(user, {}).get('identified', False) await super()._rename_user(user, new) if self._capabilities.get('account-notify', False): await self._sync_user(new, {'account': account, 'identified': identified}) ## IRC callbacks. async def on_capability_account_notify_available(self, value): """ Take note of user account changes. """ return True async def on_capability_away_notify_available(self, value): """ Take note of AWAY messages. """ return True async def on_capability_extended_join_available(self, value): """ Take note of user account and realname on JOIN. """ return True async def on_capability_multi_prefix_available(self, value): """ Thanks to how underlying client code works we already support multiple prefixes. """ return True async def on_capability_tls_available(self, value): """ We never need to request this explicitly. """ return False ## Message handlers. async def on_raw_account(self, message): """ Changes in the associated account for a nickname. """ if not self._capabilities.get('account-notify', False): return nick, metadata = self._parse_user(message.source) account = message.params[0] if nick not in self.users: return await self._sync_user(nick, metadata) if account == NO_ACCOUNT: await self._sync_user(nick, {'account': None, 'identified': False}) else: await self._sync_user(nick, {'account': account, 'identified': True}) async def on_raw_away(self, message): """ Process AWAY messages. """ if 'away-notify' not in self._capabilities or not self._capabilities['away-notify']: return nick, metadata = self._parse_user(message.source) if nick not in self.users: return await self._sync_user(nick, metadata) self.users[nick]['away'] = len(message.params) > 0 self.users[nick]['away_message'] = message.params[0] if len(message.params) > 0 else None async def on_raw_join(self, message): """ Process extended JOIN messages. """ if 'extended-join' in self._capabilities and self._capabilities['extended-join']: nick, metadata = self._parse_user(message.source) channels, account, realname = message.params await self._sync_user(nick, metadata) # Emit a fake join message. fakemsg = self._create_message('JOIN', channels, source=message.source) await super().on_raw_join(fakemsg) if account == NO_ACCOUNT: account = None self.users[nick]['account'] = account self.users[nick]['realname'] = realname else: await super().on_raw_join(message)
(self, value)
42,372
pydle.features.ircv3.ircv3_2
on_capability_invite_notify_available
Broadcast invite messages to certain other clients.
## ircv3_2.py # IRCv3.2 support (in progress). from . import ircv3_1 from . import tags from . import monitor from . import metadata __all__ = ['IRCv3_2Support'] class IRCv3_2Support(metadata.MetadataSupport, monitor.MonitoringSupport, tags.TaggedMessageSupport, ircv3_1.IRCv3_1Support): """ Support for some of IRCv3.2's extensions. """ ## IRC callbacks. async def on_capability_account_tag_available(self, value): """ Add an account message tag to user messages. """ return True async def on_capability_cap_notify_available(self, value): """ Take note of new or removed capabilities. """ return True async def on_capability_chghost_available(self, value): """ Server reply to indicate a user we are in a common channel with changed user and/or host. """ return True async def on_capability_echo_message_available(self, value): """ Echo PRIVMSG and NOTICEs back to client. """ return True async def on_capability_invite_notify_available(self, value): """ Broadcast invite messages to certain other clients. """ return True async def on_capability_userhost_in_names_available(self, value): """ Show full user!nick@host in NAMES list. We already parse it like that. """ return True async def on_capability_uhnames_available(self, value): """ Possibly outdated alias for userhost-in-names. """ return await self.on_capability_userhost_in_names_available(value) async def on_isupport_uhnames(self, value): """ Let the server know that we support UHNAMES using the old ISUPPORT method, for legacy support. """ await self.rawmsg('PROTOCTL', 'UHNAMES') ## API overrides. async def message(self, target, message): await super().message(target, message) if not self._capabilities.get('echo-message'): await self.on_message(target, self.nickname, message) if self.is_channel(target): await self.on_channel_message(target, self.nickname, message) else: await self.on_private_message(target, self.nickname, message) async def notice(self, target, message): await super().notice(target, message) if not self._capabilities.get('echo-message'): await self.on_notice(target, self.nickname, message) if self.is_channel(target): await self.on_channel_notice(target, self.nickname, message) else: await self.on_private_notice(target, self.nickname, message) ## Message handlers. async def on_raw(self, message): if 'account' in message.tags: nick, _ = self._parse_user(message.source) if nick in self.users: metadata = { 'identified': True, 'account': message.tags['account'] } await self._sync_user(nick, metadata) await super().on_raw(message) async def on_raw_chghost(self, message): """ Change user and/or host of user. """ if 'chghost' not in self._capabilities or not self._capabilities['chghost']: return nick, _ = self._parse_user(message.source) if nick not in self.users: return # Update user and host. metadata = { 'username': message.params[0], 'hostname': message.params[1] } await self._sync_user(nick, metadata)
(self, value)
42,373
pydle.features.ircv3.ircv3_3
on_capability_message_tags_available
Indicate that we can in fact parse arbitrary tags.
## ircv3_3.py # IRCv3.3 support (in progress). from . import ircv3_2 __all__ = ['IRCv3_3Support'] class IRCv3_3Support(ircv3_2.IRCv3_2Support): """ Support for some of IRCv3.3's extensions. """ ## IRC callbacks. async def on_capability_message_tags_available(self, value): """ Indicate that we can in fact parse arbitrary tags. """ return True
(self, value)
42,375
pydle.features.ircv3.monitor
on_capability_monitor_notify_available
null
def is_monitoring(self, target): """ Return whether or not we are monitoring the target's online status. """ return target in self._monitoring
(self, value)
42,376
pydle.features.ircv3.ircv3_1
on_capability_multi_prefix_available
Thanks to how underlying client code works we already support multiple prefixes.
## ircv3_1.py # IRCv3.1 full spec support. from pydle.features import account, tls from . import cap from . import sasl __all__ = ['IRCv3_1Support'] NO_ACCOUNT = '*' class IRCv3_1Support(sasl.SASLSupport, cap.CapabilityNegotiationSupport, account.AccountSupport, tls.TLSSupport): """ Support for IRCv3.1's base and optional extensions. """ async def _rename_user(self, user, new): # If the server supports account-notify, we will be told about the registration status changing. # As such, we can skip the song and dance pydle.features.account does. if self._capabilities.get('account-notify', False): account = self.users.get(user, {}).get('account', None) identified = self.users.get(user, {}).get('identified', False) await super()._rename_user(user, new) if self._capabilities.get('account-notify', False): await self._sync_user(new, {'account': account, 'identified': identified}) ## IRC callbacks. async def on_capability_account_notify_available(self, value): """ Take note of user account changes. """ return True async def on_capability_away_notify_available(self, value): """ Take note of AWAY messages. """ return True async def on_capability_extended_join_available(self, value): """ Take note of user account and realname on JOIN. """ return True async def on_capability_multi_prefix_available(self, value): """ Thanks to how underlying client code works we already support multiple prefixes. """ return True async def on_capability_tls_available(self, value): """ We never need to request this explicitly. """ return False ## Message handlers. async def on_raw_account(self, message): """ Changes in the associated account for a nickname. """ if not self._capabilities.get('account-notify', False): return nick, metadata = self._parse_user(message.source) account = message.params[0] if nick not in self.users: return await self._sync_user(nick, metadata) if account == NO_ACCOUNT: await self._sync_user(nick, {'account': None, 'identified': False}) else: await self._sync_user(nick, {'account': account, 'identified': True}) async def on_raw_away(self, message): """ Process AWAY messages. """ if 'away-notify' not in self._capabilities or not self._capabilities['away-notify']: return nick, metadata = self._parse_user(message.source) if nick not in self.users: return await self._sync_user(nick, metadata) self.users[nick]['away'] = len(message.params) > 0 self.users[nick]['away_message'] = message.params[0] if len(message.params) > 0 else None async def on_raw_join(self, message): """ Process extended JOIN messages. """ if 'extended-join' in self._capabilities and self._capabilities['extended-join']: nick, metadata = self._parse_user(message.source) channels, account, realname = message.params await self._sync_user(nick, metadata) # Emit a fake join message. fakemsg = self._create_message('JOIN', channels, source=message.source) await super().on_raw_join(fakemsg) if account == NO_ACCOUNT: account = None self.users[nick]['account'] = account self.users[nick]['realname'] = realname else: await super().on_raw_join(message)
(self, value)
42,377
pydle.features.ircv3.sasl
on_capability_sasl_available
Check whether or not SASL is available.
def _reset_attributes(self): super()._reset_attributes() self._sasl_client = None self._sasl_timer = None self._sasl_challenge = b'' self._sasl_mechanisms = None
(self, value)
42,378
pydle.features.ircv3.sasl
on_capability_sasl_enabled
Start SASL authentication.
def _reset_attributes(self): super()._reset_attributes() self._sasl_client = None self._sasl_timer = None self._sasl_challenge = b'' self._sasl_mechanisms = None
(self)
42,379
pydle.features.ircv3.ircv3_1
on_capability_tls_available
We never need to request this explicitly.
## ircv3_1.py # IRCv3.1 full spec support. from pydle.features import account, tls from . import cap from . import sasl __all__ = ['IRCv3_1Support'] NO_ACCOUNT = '*' class IRCv3_1Support(sasl.SASLSupport, cap.CapabilityNegotiationSupport, account.AccountSupport, tls.TLSSupport): """ Support for IRCv3.1's base and optional extensions. """ async def _rename_user(self, user, new): # If the server supports account-notify, we will be told about the registration status changing. # As such, we can skip the song and dance pydle.features.account does. if self._capabilities.get('account-notify', False): account = self.users.get(user, {}).get('account', None) identified = self.users.get(user, {}).get('identified', False) await super()._rename_user(user, new) if self._capabilities.get('account-notify', False): await self._sync_user(new, {'account': account, 'identified': identified}) ## IRC callbacks. async def on_capability_account_notify_available(self, value): """ Take note of user account changes. """ return True async def on_capability_away_notify_available(self, value): """ Take note of AWAY messages. """ return True async def on_capability_extended_join_available(self, value): """ Take note of user account and realname on JOIN. """ return True async def on_capability_multi_prefix_available(self, value): """ Thanks to how underlying client code works we already support multiple prefixes. """ return True async def on_capability_tls_available(self, value): """ We never need to request this explicitly. """ return False ## Message handlers. async def on_raw_account(self, message): """ Changes in the associated account for a nickname. """ if not self._capabilities.get('account-notify', False): return nick, metadata = self._parse_user(message.source) account = message.params[0] if nick not in self.users: return await self._sync_user(nick, metadata) if account == NO_ACCOUNT: await self._sync_user(nick, {'account': None, 'identified': False}) else: await self._sync_user(nick, {'account': account, 'identified': True}) async def on_raw_away(self, message): """ Process AWAY messages. """ if 'away-notify' not in self._capabilities or not self._capabilities['away-notify']: return nick, metadata = self._parse_user(message.source) if nick not in self.users: return await self._sync_user(nick, metadata) self.users[nick]['away'] = len(message.params) > 0 self.users[nick]['away_message'] = message.params[0] if len(message.params) > 0 else None async def on_raw_join(self, message): """ Process extended JOIN messages. """ if 'extended-join' in self._capabilities and self._capabilities['extended-join']: nick, metadata = self._parse_user(message.source) channels, account, realname = message.params await self._sync_user(nick, metadata) # Emit a fake join message. fakemsg = self._create_message('JOIN', channels, source=message.source) await super().on_raw_join(fakemsg) if account == NO_ACCOUNT: account = None self.users[nick]['account'] = account self.users[nick]['realname'] = realname else: await super().on_raw_join(message)
(self, value)
42,380
pydle.features.ircv3.ircv3_2
on_capability_uhnames_available
Possibly outdated alias for userhost-in-names.
## ircv3_2.py # IRCv3.2 support (in progress). from . import ircv3_1 from . import tags from . import monitor from . import metadata __all__ = ['IRCv3_2Support'] class IRCv3_2Support(metadata.MetadataSupport, monitor.MonitoringSupport, tags.TaggedMessageSupport, ircv3_1.IRCv3_1Support): """ Support for some of IRCv3.2's extensions. """ ## IRC callbacks. async def on_capability_account_tag_available(self, value): """ Add an account message tag to user messages. """ return True async def on_capability_cap_notify_available(self, value): """ Take note of new or removed capabilities. """ return True async def on_capability_chghost_available(self, value): """ Server reply to indicate a user we are in a common channel with changed user and/or host. """ return True async def on_capability_echo_message_available(self, value): """ Echo PRIVMSG and NOTICEs back to client. """ return True async def on_capability_invite_notify_available(self, value): """ Broadcast invite messages to certain other clients. """ return True async def on_capability_userhost_in_names_available(self, value): """ Show full user!nick@host in NAMES list. We already parse it like that. """ return True async def on_capability_uhnames_available(self, value): """ Possibly outdated alias for userhost-in-names. """ return await self.on_capability_userhost_in_names_available(value) async def on_isupport_uhnames(self, value): """ Let the server know that we support UHNAMES using the old ISUPPORT method, for legacy support. """ await self.rawmsg('PROTOCTL', 'UHNAMES') ## API overrides. async def message(self, target, message): await super().message(target, message) if not self._capabilities.get('echo-message'): await self.on_message(target, self.nickname, message) if self.is_channel(target): await self.on_channel_message(target, self.nickname, message) else: await self.on_private_message(target, self.nickname, message) async def notice(self, target, message): await super().notice(target, message) if not self._capabilities.get('echo-message'): await self.on_notice(target, self.nickname, message) if self.is_channel(target): await self.on_channel_notice(target, self.nickname, message) else: await self.on_private_notice(target, self.nickname, message) ## Message handlers. async def on_raw(self, message): if 'account' in message.tags: nick, _ = self._parse_user(message.source) if nick in self.users: metadata = { 'identified': True, 'account': message.tags['account'] } await self._sync_user(nick, metadata) await super().on_raw(message) async def on_raw_chghost(self, message): """ Change user and/or host of user. """ if 'chghost' not in self._capabilities or not self._capabilities['chghost']: return nick, _ = self._parse_user(message.source) if nick not in self.users: return # Update user and host. metadata = { 'username': message.params[0], 'hostname': message.params[1] } await self._sync_user(nick, metadata)
(self, value)
42,381
pydle.features.ircv3.ircv3_2
on_capability_userhost_in_names_available
Show full user!nick@host in NAMES list. We already parse it like that.
## ircv3_2.py # IRCv3.2 support (in progress). from . import ircv3_1 from . import tags from . import monitor from . import metadata __all__ = ['IRCv3_2Support'] class IRCv3_2Support(metadata.MetadataSupport, monitor.MonitoringSupport, tags.TaggedMessageSupport, ircv3_1.IRCv3_1Support): """ Support for some of IRCv3.2's extensions. """ ## IRC callbacks. async def on_capability_account_tag_available(self, value): """ Add an account message tag to user messages. """ return True async def on_capability_cap_notify_available(self, value): """ Take note of new or removed capabilities. """ return True async def on_capability_chghost_available(self, value): """ Server reply to indicate a user we are in a common channel with changed user and/or host. """ return True async def on_capability_echo_message_available(self, value): """ Echo PRIVMSG and NOTICEs back to client. """ return True async def on_capability_invite_notify_available(self, value): """ Broadcast invite messages to certain other clients. """ return True async def on_capability_userhost_in_names_available(self, value): """ Show full user!nick@host in NAMES list. We already parse it like that. """ return True async def on_capability_uhnames_available(self, value): """ Possibly outdated alias for userhost-in-names. """ return await self.on_capability_userhost_in_names_available(value) async def on_isupport_uhnames(self, value): """ Let the server know that we support UHNAMES using the old ISUPPORT method, for legacy support. """ await self.rawmsg('PROTOCTL', 'UHNAMES') ## API overrides. async def message(self, target, message): await super().message(target, message) if not self._capabilities.get('echo-message'): await self.on_message(target, self.nickname, message) if self.is_channel(target): await self.on_channel_message(target, self.nickname, message) else: await self.on_private_message(target, self.nickname, message) async def notice(self, target, message): await super().notice(target, message) if not self._capabilities.get('echo-message'): await self.on_notice(target, self.nickname, message) if self.is_channel(target): await self.on_channel_notice(target, self.nickname, message) else: await self.on_private_notice(target, self.nickname, message) ## Message handlers. async def on_raw(self, message): if 'account' in message.tags: nick, _ = self._parse_user(message.source) if nick in self.users: metadata = { 'identified': True, 'account': message.tags['account'] } await self._sync_user(nick, metadata) await super().on_raw(message) async def on_raw_chghost(self, message): """ Change user and/or host of user. """ if 'chghost' not in self._capabilities or not self._capabilities['chghost']: return nick, _ = self._parse_user(message.source) if nick not in self.users: return # Update user and host. metadata = { 'username': message.params[0], 'hostname': message.params[1] } await self._sync_user(nick, metadata)
(self, value)
42,382
pydle.features.rfc1459.client
on_channel_message
Callback received when the client received a message in a channel.
def is_same_channel(self, left, right): """ Check if given nicknames are equal in the server's case mapping. """ return self.normalize(left) == self.normalize(right)
(self, target, by, message)
42,383
pydle.features.rfc1459.client
on_channel_notice
Callback called when the client received a notice in a channel.
def is_same_channel(self, left, right): """ Check if given nicknames are equal in the server's case mapping. """ return self.normalize(left) == self.normalize(right)
(self, target, by, message)
42,384
pydle.features.rfc1459.client
on_connect
null
def is_same_channel(self, left, right): """ Check if given nicknames are equal in the server's case mapping. """ return self.normalize(left) == self.normalize(right)
(self)
42,385
pydle.features.ctcp
on_ctcp
Callback called when the user received a CTCP message. Client subclasses can override on_ctcp_<type> to be called when receiving a message of that specific CTCP type, in addition to this callback.
## ctcp.py # Client-to-Client-Protocol (CTCP) support. import pydle import pydle.protocol from pydle.features import rfc1459 from pydle import client __all__ = ['CTCPSupport'] CTCP_DELIMITER = '\x01' CTCP_ESCAPE_CHAR = '\x16' class CTCPSupport(rfc1459.RFC1459Support): """ Support for CTCP messages. """ ## Callbacks. async def on_ctcp(self, by, target, what, contents): """ Callback called when the user received a CTCP message. Client subclasses can override on_ctcp_<type> to be called when receiving a message of that specific CTCP type, in addition to this callback. """ ... async def on_ctcp_reply(self, by, target, what, response): """ Callback called when the user received a CTCP response. Client subclasses can override on_ctcp_<type>_reply to be called when receiving a reply of that specific CTCP type, in addition to this callback. """ ... async def on_ctcp_version(self, by, target, contents): """ Built-in CTCP version as some networks seem to require it. """ version = '{name} v{ver}'.format(name=pydle.__name__, ver=pydle.__version__) await self.ctcp_reply(by, 'VERSION', version) ## IRC API. async def ctcp(self, target, query, contents=None): """ Send a CTCP request to a target. """ if self.is_channel(target) and not self.in_channel(target): raise client.NotInChannel(target) await self.message(target, construct_ctcp(query, contents)) async def ctcp_reply(self, target, query, response): """ Send a CTCP reply to a target. """ if self.is_channel(target) and not self.in_channel(target): raise client.NotInChannel(target) await self.notice(target, construct_ctcp(query, response)) ## Handler overrides. async def on_raw_privmsg(self, message): """ Modify PRIVMSG to redirect CTCP messages. """ nick, metadata = self._parse_user(message.source) target, msg = message.params if is_ctcp(msg): await self._sync_user(nick, metadata) type, contents = parse_ctcp(msg) # Find dedicated handler if it exists. attr = 'on_ctcp_' + pydle.protocol.identifierify(type) if hasattr(self, attr): await getattr(self, attr)(nick, target, contents) # Invoke global handler. await self.on_ctcp(nick, target, type, contents) else: await super().on_raw_privmsg(message) async def on_raw_notice(self, message): """ Modify NOTICE to redirect CTCP messages. """ nick, metadata = self._parse_user(message.source) target, msg = message.params if is_ctcp(msg): await self._sync_user(nick, metadata) _type, response = parse_ctcp(msg) # Find dedicated handler if it exists. attr = 'on_ctcp_' + pydle.protocol.identifierify(_type) + '_reply' if hasattr(self, attr): await getattr(self, attr)(nick, target, response) # Invoke global handler. await self.on_ctcp_reply(nick, target, _type, response) else: await super().on_raw_notice(message)
(self, by, target, what, contents)
42,386
pydle.features.ctcp
on_ctcp_reply
Callback called when the user received a CTCP response. Client subclasses can override on_ctcp_<type>_reply to be called when receiving a reply of that specific CTCP type, in addition to this callback.
## ctcp.py # Client-to-Client-Protocol (CTCP) support. import pydle import pydle.protocol from pydle.features import rfc1459 from pydle import client __all__ = ['CTCPSupport'] CTCP_DELIMITER = '\x01' CTCP_ESCAPE_CHAR = '\x16' class CTCPSupport(rfc1459.RFC1459Support): """ Support for CTCP messages. """ ## Callbacks. async def on_ctcp(self, by, target, what, contents): """ Callback called when the user received a CTCP message. Client subclasses can override on_ctcp_<type> to be called when receiving a message of that specific CTCP type, in addition to this callback. """ ... async def on_ctcp_reply(self, by, target, what, response): """ Callback called when the user received a CTCP response. Client subclasses can override on_ctcp_<type>_reply to be called when receiving a reply of that specific CTCP type, in addition to this callback. """ ... async def on_ctcp_version(self, by, target, contents): """ Built-in CTCP version as some networks seem to require it. """ version = '{name} v{ver}'.format(name=pydle.__name__, ver=pydle.__version__) await self.ctcp_reply(by, 'VERSION', version) ## IRC API. async def ctcp(self, target, query, contents=None): """ Send a CTCP request to a target. """ if self.is_channel(target) and not self.in_channel(target): raise client.NotInChannel(target) await self.message(target, construct_ctcp(query, contents)) async def ctcp_reply(self, target, query, response): """ Send a CTCP reply to a target. """ if self.is_channel(target) and not self.in_channel(target): raise client.NotInChannel(target) await self.notice(target, construct_ctcp(query, response)) ## Handler overrides. async def on_raw_privmsg(self, message): """ Modify PRIVMSG to redirect CTCP messages. """ nick, metadata = self._parse_user(message.source) target, msg = message.params if is_ctcp(msg): await self._sync_user(nick, metadata) type, contents = parse_ctcp(msg) # Find dedicated handler if it exists. attr = 'on_ctcp_' + pydle.protocol.identifierify(type) if hasattr(self, attr): await getattr(self, attr)(nick, target, contents) # Invoke global handler. await self.on_ctcp(nick, target, type, contents) else: await super().on_raw_privmsg(message) async def on_raw_notice(self, message): """ Modify NOTICE to redirect CTCP messages. """ nick, metadata = self._parse_user(message.source) target, msg = message.params if is_ctcp(msg): await self._sync_user(nick, metadata) _type, response = parse_ctcp(msg) # Find dedicated handler if it exists. attr = 'on_ctcp_' + pydle.protocol.identifierify(_type) + '_reply' if hasattr(self, attr): await getattr(self, attr)(nick, target, response) # Invoke global handler. await self.on_ctcp_reply(nick, target, _type, response) else: await super().on_raw_notice(message)
(self, by, target, what, response)
42,387
pydle.features.ctcp
on_ctcp_version
Built-in CTCP version as some networks seem to require it.
## ctcp.py # Client-to-Client-Protocol (CTCP) support. import pydle import pydle.protocol from pydle.features import rfc1459 from pydle import client __all__ = ['CTCPSupport'] CTCP_DELIMITER = '\x01' CTCP_ESCAPE_CHAR = '\x16' class CTCPSupport(rfc1459.RFC1459Support): """ Support for CTCP messages. """ ## Callbacks. async def on_ctcp(self, by, target, what, contents): """ Callback called when the user received a CTCP message. Client subclasses can override on_ctcp_<type> to be called when receiving a message of that specific CTCP type, in addition to this callback. """ ... async def on_ctcp_reply(self, by, target, what, response): """ Callback called when the user received a CTCP response. Client subclasses can override on_ctcp_<type>_reply to be called when receiving a reply of that specific CTCP type, in addition to this callback. """ ... async def on_ctcp_version(self, by, target, contents): """ Built-in CTCP version as some networks seem to require it. """ version = '{name} v{ver}'.format(name=pydle.__name__, ver=pydle.__version__) await self.ctcp_reply(by, 'VERSION', version) ## IRC API. async def ctcp(self, target, query, contents=None): """ Send a CTCP request to a target. """ if self.is_channel(target) and not self.in_channel(target): raise client.NotInChannel(target) await self.message(target, construct_ctcp(query, contents)) async def ctcp_reply(self, target, query, response): """ Send a CTCP reply to a target. """ if self.is_channel(target) and not self.in_channel(target): raise client.NotInChannel(target) await self.notice(target, construct_ctcp(query, response)) ## Handler overrides. async def on_raw_privmsg(self, message): """ Modify PRIVMSG to redirect CTCP messages. """ nick, metadata = self._parse_user(message.source) target, msg = message.params if is_ctcp(msg): await self._sync_user(nick, metadata) type, contents = parse_ctcp(msg) # Find dedicated handler if it exists. attr = 'on_ctcp_' + pydle.protocol.identifierify(type) if hasattr(self, attr): await getattr(self, attr)(nick, target, contents) # Invoke global handler. await self.on_ctcp(nick, target, type, contents) else: await super().on_raw_privmsg(message) async def on_raw_notice(self, message): """ Modify NOTICE to redirect CTCP messages. """ nick, metadata = self._parse_user(message.source) target, msg = message.params if is_ctcp(msg): await self._sync_user(nick, metadata) _type, response = parse_ctcp(msg) # Find dedicated handler if it exists. attr = 'on_ctcp_' + pydle.protocol.identifierify(_type) + '_reply' if hasattr(self, attr): await getattr(self, attr)(nick, target, response) # Invoke global handler. await self.on_ctcp_reply(nick, target, _type, response) else: await super().on_raw_notice(message)
(self, by, target, contents)
42,391
pydle.features.rfc1459.client
on_invite
Callback called when the client was invited into a channel by someone.
def is_same_channel(self, left, right): """ Check if given nicknames are equal in the server's case mapping. """ return self.normalize(left) == self.normalize(right)
(self, channel, by)
42,392
pydle.features.isupport
on_isupport_awaylen
Away message length limit.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,393
pydle.features.isupport
on_isupport_casemapping
IRC case mapping for nickname and channel name comparisons.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,394
pydle.features.isupport
on_isupport_chanlimit
Simultaneous channel limits for user.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,395
pydle.features.isupport
on_isupport_chanmodes
Valid channel modes and their behaviour.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,396
pydle.features.isupport
on_isupport_channellen
Channel name length limit.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,397
pydle.features.isupport
on_isupport_chantypes
Channel name prefix symbols.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,398
pydle.features.isupport
on_isupport_excepts
Server allows ban exceptions.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,399
pydle.features.isupport
on_isupport_extban
Extended ban prefixes.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,400
pydle.features.isupport
on_isupport_invex
Server allows invite exceptions.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,401
pydle.features.isupport
on_isupport_maxbans
Maximum entries in ban list. Replaced by MAXLIST.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,402
pydle.features.isupport
on_isupport_maxchannels
Old version of CHANLIMIT.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,403
pydle.features.isupport
on_isupport_maxlist
Limits on channel modes involving lists.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,404
pydle.features.isupport
on_isupport_maxpara
Limits to parameters given to command.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,405
pydle.features.isupport
on_isupport_modes
Maximum number of variable modes to change in a single MODE command.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,406
pydle.features.isupport
on_isupport_monitor
null
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,407
pydle.features.isupport
on_isupport_namesx
Let the server know we do in fact support NAMESX. Effectively the same as CAP multi-prefix.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,408
pydle.features.isupport
on_isupport_network
IRC network name.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,409
pydle.features.isupport
on_isupport_nicklen
Nickname length limit.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,410
pydle.features.isupport
on_isupport_prefix
Nickname prefixes on channels and their associated modes.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,411
pydle.features.isupport
on_isupport_statusmsg
Support for messaging every member on a channel with given status or higher.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,412
pydle.features.isupport
on_isupport_targmax
The maximum number of targets certain types of commands can affect.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,413
pydle.features.isupport
on_isupport_topiclen
Channel topic length limit.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,414
pydle.features.ircv3.ircv3_2
on_isupport_uhnames
Let the server know that we support UHNAMES using the old ISUPPORT method, for legacy support.
## ircv3_2.py # IRCv3.2 support (in progress). from . import ircv3_1 from . import tags from . import monitor from . import metadata __all__ = ['IRCv3_2Support'] class IRCv3_2Support(metadata.MetadataSupport, monitor.MonitoringSupport, tags.TaggedMessageSupport, ircv3_1.IRCv3_1Support): """ Support for some of IRCv3.2's extensions. """ ## IRC callbacks. async def on_capability_account_tag_available(self, value): """ Add an account message tag to user messages. """ return True async def on_capability_cap_notify_available(self, value): """ Take note of new or removed capabilities. """ return True async def on_capability_chghost_available(self, value): """ Server reply to indicate a user we are in a common channel with changed user and/or host. """ return True async def on_capability_echo_message_available(self, value): """ Echo PRIVMSG and NOTICEs back to client. """ return True async def on_capability_invite_notify_available(self, value): """ Broadcast invite messages to certain other clients. """ return True async def on_capability_userhost_in_names_available(self, value): """ Show full user!nick@host in NAMES list. We already parse it like that. """ return True async def on_capability_uhnames_available(self, value): """ Possibly outdated alias for userhost-in-names. """ return await self.on_capability_userhost_in_names_available(value) async def on_isupport_uhnames(self, value): """ Let the server know that we support UHNAMES using the old ISUPPORT method, for legacy support. """ await self.rawmsg('PROTOCTL', 'UHNAMES') ## API overrides. async def message(self, target, message): await super().message(target, message) if not self._capabilities.get('echo-message'): await self.on_message(target, self.nickname, message) if self.is_channel(target): await self.on_channel_message(target, self.nickname, message) else: await self.on_private_message(target, self.nickname, message) async def notice(self, target, message): await super().notice(target, message) if not self._capabilities.get('echo-message'): await self.on_notice(target, self.nickname, message) if self.is_channel(target): await self.on_channel_notice(target, self.nickname, message) else: await self.on_private_notice(target, self.nickname, message) ## Message handlers. async def on_raw(self, message): if 'account' in message.tags: nick, _ = self._parse_user(message.source) if nick in self.users: metadata = { 'identified': True, 'account': message.tags['account'] } await self._sync_user(nick, metadata) await super().on_raw(message) async def on_raw_chghost(self, message): """ Change user and/or host of user. """ if 'chghost' not in self._capabilities or not self._capabilities['chghost']: return nick, _ = self._parse_user(message.source) if nick not in self.users: return # Update user and host. metadata = { 'username': message.params[0], 'hostname': message.params[1] } await self._sync_user(nick, metadata)
(self, value)
42,415
pydle.features.isupport
on_isupport_wallchops
Support for messaging every opped member or higher on a channel. Replaced by STATUSMSG.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,416
pydle.features.isupport
on_isupport_wallvoices
Support for messaging every voiced member or higher on a channel. Replaced by STATUSMSG.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, value)
42,417
pydle.features.rfc1459.client
on_join
Callback called when a user, possibly the client, has joined the channel.
def is_same_channel(self, left, right): """ Check if given nicknames are equal in the server's case mapping. """ return self.normalize(left) == self.normalize(right)
(self, channel, user)
42,418
pydle.features.rfc1459.client
on_kick
Callback called when a user, possibly the client, was kicked from a channel.
def is_same_channel(self, left, right): """ Check if given nicknames are equal in the server's case mapping. """ return self.normalize(left) == self.normalize(right)
(self, channel, target, by, reason=None)
42,419
pydle.features.rfc1459.client
on_kill
Callback called when a user, possibly the client, was killed from the server.
def is_same_channel(self, left, right): """ Check if given nicknames are equal in the server's case mapping. """ return self.normalize(left) == self.normalize(right)
(self, target, by, reason)
42,420
pydle.features.rfc1459.client
on_message
Callback called when the client received a message.
def is_same_channel(self, left, right): """ Check if given nicknames are equal in the server's case mapping. """ return self.normalize(left) == self.normalize(right)
(self, target, by, message)
42,422
pydle.features.rfc1459.client
on_mode_change
Callback called when the mode on a channel was changed.
def is_same_channel(self, left, right): """ Check if given nicknames are equal in the server's case mapping. """ return self.normalize(left) == self.normalize(right)
(self, channel, modes, by)
42,423
pydle.features.rfc1459.client
on_nick_change
Callback called when a user, possibly the client, changed their nickname.
def is_same_channel(self, left, right): """ Check if given nicknames are equal in the server's case mapping. """ return self.normalize(left) == self.normalize(right)
(self, old, new)
42,424
pydle.features.rfc1459.client
on_notice
Callback called when the client received a notice.
def is_same_channel(self, left, right): """ Check if given nicknames are equal in the server's case mapping. """ return self.normalize(left) == self.normalize(right)
(self, target, by, message)
42,425
pydle.features.rfc1459.client
on_part
Callback called when a user, possibly the client, left a channel.
def is_same_channel(self, left, right): """ Check if given nicknames are equal in the server's case mapping. """ return self.normalize(left) == self.normalize(right)
(self, channel, user, message=None)
42,426
pydle.features.rfc1459.client
on_private_message
Callback called when the client received a message in private.
def is_same_channel(self, left, right): """ Check if given nicknames are equal in the server's case mapping. """ return self.normalize(left) == self.normalize(right)
(self, target, by, message)
42,427
pydle.features.rfc1459.client
on_private_notice
Callback called when the client received a notice in private.
def is_same_channel(self, left, right): """ Check if given nicknames are equal in the server's case mapping. """ return self.normalize(left) == self.normalize(right)
(self, target, by, message)
42,428
pydle.features.rfc1459.client
on_quit
Callback called when a user, possibly the client, left the network.
def is_same_channel(self, left, right): """ Check if given nicknames are equal in the server's case mapping. """ return self.normalize(left) == self.normalize(right)
(self, user, message=None)
42,433
pydle.features.rfc1459.client
on_raw_004
Basic server information.
def is_same_channel(self, left, right): """ Check if given nicknames are equal in the server's case mapping. """ return self.normalize(left) == self.normalize(right)
(self, message)
42,434
pydle.features.isupport
on_raw_005
ISUPPORT indication.
def _create_channel(self, channel): """ Create channel with optional ban and invite exception lists. """ super()._create_channel(channel) if 'EXCEPTS' in self._isupport: self.channels[channel]['exceptlist'] = None if 'INVEX' in self._isupport: self.channels[channel]['inviteexceptlist'] = None
(self, message)