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,445
pydle.features.rfc1459.client
on_raw_301
User is away.
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,446
pydle.features.account
on_raw_307
WHOIS: User has identified for this nickname. (Anope)
def _create_user(self, nickname): super()._create_user(nickname) if nickname in self.users: self.users[nickname].update({ 'account': None, 'identified': False })
(self, message)
42,447
pydle.features.rfc1459.client
on_raw_311
WHOIS user info.
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,448
pydle.features.rfc1459.client
on_raw_312
WHOIS server info.
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,449
pydle.features.rfc1459.client
on_raw_313
WHOIS operator info.
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,450
pydle.features.rfc1459.client
on_raw_314
WHOWAS user info.
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,452
pydle.features.rfc1459.client
on_raw_317
WHOIS idle time.
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,453
pydle.features.rfc1459.client
on_raw_318
End of /WHOIS list.
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,454
pydle.features.rfc1459.client
on_raw_319
WHOIS active channels.
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,455
pydle.features.rfc1459.client
on_raw_324
Channel mode.
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,456
pydle.features.rfc1459.client
on_raw_329
Channel creation time.
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,457
pydle.features.account
on_raw_330
WHOIS account name (Atheme).
def _create_user(self, nickname): super()._create_user(nickname) if nickname in self.users: self.users[nickname].update({ 'account': None, 'identified': False })
(self, message)
42,458
pydle.features.rfc1459.client
on_raw_332
Current topic on channel join.
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,459
pydle.features.rfc1459.client
on_raw_333
Topic setter and time on channel join.
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,460
pydle.features.rfc1459.client
on_raw_353
Response to /NAMES.
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,461
pydle.features.whox
on_raw_354
WHOX results have arrived.
## 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, message)
42,463
pydle.features.rfc1459.client
on_raw_372
Append message of the day.
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,464
pydle.features.rfc1459.client
on_raw_375
Start message of the day.
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,465
pydle.features.rfc1459.client
on_raw_376
End of message of the day.
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,466
pydle.features.rpl_whoishost.rpl_whoishost
on_raw_378
handles a RPL_WHOISHOST message
from pydle.features.rfc1459 import RFC1459Support class RplWhoisHostSupport(RFC1459Support): """ Adds support for RPL_WHOISHOST messages (378) """ async def on_raw_378(self, message): """ handles a RPL_WHOISHOST message """ _, target, data = message.params data = data.split(" ") target = message.params[1] ip_addr = data[-1] host = data[-2] meta = {"real_ip_address": ip_addr, "real_hostname": host} await self._sync_user(target, meta) if target in self._whois_info: self._whois_info[target]["real_ip_address"] = ip_addr self._whois_info[target]["real_hostname"] = host async def whois(self, nickname): info = await super().whois(nickname) if info is None: return info info.setdefault("real_ip_address", None) info.setdefault("real_hostname", None) return info
(self, message)
42,467
pydle.features.rfc1459.client
on_raw_401
No such nick/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, message)
42,468
pydle.features.rfc1459.client
on_raw_402
No such 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, message)
42,469
pydle.features.ircv3.cap
on_raw_410
Unknown CAP subcommand or CAP error. Force-end negotiations.
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, message)
42,470
pydle.features.ircv3.cap
on_raw_421
Hijack to ignore the absence of a CAP command.
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, message)
42,471
pydle.features.rfc1459.client
on_raw_422
MOTD is missing.
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,472
pydle.features.rfc1459.client
on_raw_432
Erroneous 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, message)
42,473
pydle.features.rfc1459.client
on_raw_433
Nickname in use.
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,477
pydle.features.tls
on_raw_671
WHOIS: user is connected securely.
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, message)
42,478
pydle.features.ircv3.monitor
on_raw_730
Someone we are monitoring just came online.
def is_monitoring(self, target): """ Return whether or not we are monitoring the target's online status. """ return target in self._monitoring
(self, message)
42,479
pydle.features.ircv3.monitor
on_raw_731
Someone we are monitoring got offline.
def is_monitoring(self, target): """ Return whether or not we are monitoring the target's online status. """ return target in self._monitoring
(self, message)
42,480
pydle.features.ircv3.monitor
on_raw_732
List of users we're monitoring.
def is_monitoring(self, target): """ Return whether or not we are monitoring the target's online status. """ return target in self._monitoring
(self, message)
42,482
pydle.features.ircv3.monitor
on_raw_734
Monitor list is full, can't add target.
def is_monitoring(self, target): """ Return whether or not we are monitoring the target's online status. """ return target in self._monitoring
(self, message)
42,483
pydle.features.ircv3.metadata
on_raw_760
Metadata key/value for whois.
def _reset_attributes(self): super()._reset_attributes() self._pending['metadata'] = {} self._metadata_info = {} self._metadata_queue = []
(self, message)
42,484
pydle.features.ircv3.metadata
on_raw_761
Metadata key/value.
def _reset_attributes(self): super()._reset_attributes() self._pending['metadata'] = {} self._metadata_info = {} self._metadata_queue = []
(self, message)
42,485
pydle.features.ircv3.metadata
on_raw_762
End of metadata.
def _reset_attributes(self): super()._reset_attributes() self._pending['metadata'] = {} self._metadata_info = {} self._metadata_queue = []
(self, message)
42,486
pydle.features.ircv3.metadata
on_raw_764
Metadata limit reached.
def _reset_attributes(self): super()._reset_attributes() self._pending['metadata'] = {} self._metadata_info = {} self._metadata_queue = []
(self, message)
42,487
pydle.features.ircv3.metadata
on_raw_765
Invalid metadata target.
def _reset_attributes(self): super()._reset_attributes() self._pending['metadata'] = {} self._metadata_info = {} self._metadata_queue = []
(self, message)
42,488
pydle.features.ircv3.metadata
on_raw_766
Unknown metadata key.
def _reset_attributes(self): super()._reset_attributes() self._pending['metadata'] = {} self._metadata_info = {} self._metadata_queue = []
(self, message)
42,489
pydle.features.ircv3.metadata
on_raw_767
Invalid metadata key.
def _reset_attributes(self): super()._reset_attributes() self._pending['metadata'] = {} self._metadata_info = {} self._metadata_queue = []
(self, message)
42,490
pydle.features.ircv3.metadata
on_raw_768
Metadata key not set.
def _reset_attributes(self): super()._reset_attributes() self._pending['metadata'] = {} self._metadata_info = {} self._metadata_queue = []
(self, message)
42,491
pydle.features.ircv3.metadata
on_raw_769
Metadata permission denied.
def _reset_attributes(self): super()._reset_attributes() self._pending['metadata'] = {} self._metadata_info = {} self._metadata_queue = []
(self, message)
42,493
pydle.features.ircv3.sasl
on_raw_903
SASL authentication successful.
def _reset_attributes(self): super()._reset_attributes() self._sasl_client = None self._sasl_timer = None self._sasl_challenge = b'' self._sasl_mechanisms = None
(self, message)
42,494
pydle.features.ircv3.sasl
on_raw_904
Invalid mechanism or authentication failed. Abort SASL.
def _reset_attributes(self): super()._reset_attributes() self._sasl_client = None self._sasl_timer = None self._sasl_challenge = b'' self._sasl_mechanisms = None
(self, message)
42,495
pydle.features.ircv3.sasl
on_raw_905
Authentication failed. Abort SASL.
def _reset_attributes(self): super()._reset_attributes() self._sasl_client = None self._sasl_timer = None self._sasl_challenge = b'' self._sasl_mechanisms = None
(self, message)
42,498
pydle.features.ircv3.ircv3_1
on_raw_account
Changes in the associated account for a nickname.
## 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, message)
42,499
pydle.features.ircv3.sasl
on_raw_authenticate
Received part of the authentication challenge.
def _reset_attributes(self): super()._reset_attributes() self._sasl_client = None self._sasl_timer = None self._sasl_challenge = b'' self._sasl_mechanisms = None
(self, message)
42,500
pydle.features.ircv3.ircv3_1
on_raw_away
Process 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, message)
42,501
pydle.features.ircv3.cap
on_raw_cap
Handle CAP message.
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, message)
42,502
pydle.features.ircv3.cap
on_raw_cap_ack
Update active capabilities: requested capability accepted.
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, params)
42,504
pydle.features.ircv3.cap
on_raw_cap_list
Update active capabilities.
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, params)
42,505
pydle.features.ircv3.cap
on_raw_cap_ls
Update capability mapping. Request capabilities.
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, params)
42,506
pydle.features.ircv3.cap
on_raw_cap_nak
Update active capabilities: requested capability rejected.
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, params)
42,508
pydle.features.ircv3.ircv3_2
on_raw_chghost
Change user and/or host of user.
## 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, message)
42,509
pydle.features.rfc1459.client
on_raw_error
Server encountered an error and will now close the connection.
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,510
pydle.features.rfc1459.client
on_raw_invite
INVITE command.
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,511
pydle.features.whox
on_raw_join
Override JOIN to send WHOX.
## 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, message)
42,512
pydle.features.rfc1459.client
on_raw_kick
KICK command.
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,513
pydle.features.rfc1459.client
on_raw_kill
KILL command.
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,514
pydle.features.ircv3.metadata
on_raw_metadata
Metadata event.
def _reset_attributes(self): super()._reset_attributes() self._pending['metadata'] = {} self._metadata_info = {} self._metadata_queue = []
(self, message)
42,515
pydle.features.rfc1459.client
on_raw_mode
MODE command.
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,516
pydle.features.rfc1459.client
on_raw_nick
NICK command.
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,517
pydle.features.ctcp
on_raw_notice
Modify NOTICE to redirect CTCP messages.
## 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, message)
42,518
pydle.features.rfc1459.client
on_raw_part
PART command.
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,519
pydle.features.rfc1459.client
on_raw_ping
PING command.
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,521
pydle.features.ctcp
on_raw_privmsg
Modify PRIVMSG to redirect CTCP messages.
## 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, message)
42,522
pydle.features.rfc1459.client
on_raw_quit
QUIT command.
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,523
pydle.features.rfc1459.client
on_raw_topic
TOPIC command.
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,524
pydle.features.rfc1459.client
on_topic_change
Callback called when the topic for 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, message, by)
42,526
pydle.features.rfc1459.client
on_user_invite
Callback called when another user 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, target, channel, by)
42,527
pydle.features.rfc1459.client
on_user_mode_change
Callback called when a user mode change occurred for the client.
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, modes)
42,528
pydle.features.ircv3.monitor
on_user_offline
Callback called when a monitored users goes offline.
def is_monitoring(self, target): """ Return whether or not we are monitoring the target's online status. """ return target in self._monitoring
(self, nickname)
42,529
pydle.features.ircv3.monitor
on_user_online
Callback called when a monitored user appears online.
def is_monitoring(self, target): """ Return whether or not we are monitoring the target's online status. """ return target in self._monitoring
(self, nickname)
42,530
pydle.features.rfc1459.client
part
Leave channel, optionally with message.
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, message=None)
42,531
pydle.features.rfc1459.client
quit
Quit network.
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=None)
42,536
pydle.features.rfc1459.client
set_mode
Set mode on target. Users should only rely on the mode actually being changed when receiving an on_{channel,user}_mode_change callback.
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, target, *modes)
42,537
pydle.features.rfc1459.client
set_nickname
Set nickname to given nickname. Users should only rely on the nickname actually being changed when receiving an on_nick_change callback.
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, nickname)
42,538
pydle.features.rfc1459.client
set_topic
Set topic on channel. Users should only rely on the topic actually being changed when receiving an on_topic_change callback.
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, topic)
42,539
pydle.features.rfc1459.client
unban
Unban user from channel. Target can be either a user or a host. See ban documentation for the range parameter.
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,540
pydle.features.ircv3.monitor
unmonitor
Stop 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,542
pydle.features.account
whois
null
def _create_user(self, nickname): super()._create_user(nickname) if nickname in self.users: self.users[nickname].update({ 'account': None, 'identified': False })
(self, nickname)
42,543
pydle.features.rfc1459.client
whowas
Return information about offline user. This is an blocking asynchronous method: it has to be called from a coroutine, as follows: info = await self.whowas('Nick')
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, nickname)
42,544
pydle.client
ClientPool
A pool of clients that are ran and handled in parallel.
class ClientPool: """ A pool of clients that are ran and handled in parallel. """ def __init__(self, clients=None, eventloop=None): self.eventloop = eventloop if eventloop else new_event_loop() self.clients = set(clients or []) self.connect_args = {} def connect(self, client: BasicClient, *args, **kwargs): """ Add client to pool. """ self.clients.add(client) self.connect_args[client] = (args, kwargs) # hack the clients event loop to use the pools own event loop client.eventloop = self.eventloop # necessary to run multiple clients in the same thread via the pool def disconnect(self, client): """ Remove client from pool. """ self.clients.remove(client) del self.connect_args[client] asyncio.run_coroutine_threadsafe(client.disconnect(expected=True), self.eventloop) def __contains__(self, item): return item in self.clients ## High-level. def handle_forever(self): """ Main loop of the pool: handle clients forever, until the event loop is stopped. """ # container for all the client connection coros connection_list = [] for client in self.clients: args, kwargs = self.connect_args[client] connection_list.append(client.connect(*args, **kwargs)) # single future for executing the connections connections = gather(*connection_list, loop=self.eventloop) # run the connections self.eventloop.run_until_complete(connections) # run the clients self.eventloop.run_forever()
(clients=None, eventloop=None)
42,545
pydle.client
__contains__
null
def __contains__(self, item): return item in self.clients
(self, item)
42,546
pydle.client
__init__
null
def __init__(self, clients=None, eventloop=None): self.eventloop = eventloop if eventloop else new_event_loop() self.clients = set(clients or []) self.connect_args = {}
(self, clients=None, eventloop=None)
42,547
pydle.client
connect
Add client to pool.
def connect(self, client: BasicClient, *args, **kwargs): """ Add client to pool. """ self.clients.add(client) self.connect_args[client] = (args, kwargs) # hack the clients event loop to use the pools own event loop client.eventloop = self.eventloop # necessary to run multiple clients in the same thread via the pool
(self, client: pydle.client.BasicClient, *args, **kwargs)
42,548
pydle.client
disconnect
Remove client from pool.
def disconnect(self, client): """ Remove client from pool. """ self.clients.remove(client) del self.connect_args[client] asyncio.run_coroutine_threadsafe(client.disconnect(expected=True), self.eventloop)
(self, client)
42,549
pydle.client
handle_forever
Main loop of the pool: handle clients forever, until the event loop is stopped.
def handle_forever(self): """ Main loop of the pool: handle clients forever, until the event loop is stopped. """ # container for all the client connection coros connection_list = [] for client in self.clients: args, kwargs = self.connect_args[client] connection_list.append(client.connect(*args, **kwargs)) # single future for executing the connections connections = gather(*connection_list, loop=self.eventloop) # run the connections self.eventloop.run_until_complete(connections) # run the clients self.eventloop.run_forever()
(self)
42,550
pydle.client
Error
Base class for all pydle errors.
class Error(Exception): """ Base class for all pydle errors. """ ...
null
42,551
_asyncio
Future
This class is *almost* compatible with concurrent.futures.Future. Differences: - result() and exception() do not take a timeout argument and raise an exception when the future isn't done yet. - Callbacks registered with add_done_callback() are always called via the event loop's call_soon_threadsafe(). - This class is not compatible with the wait() and as_completed() methods in the concurrent.futures package.
from _asyncio import Future
(*, loop=None)
42,552
pydle
MinimalClient
A cut-down, less-featured IRC client.
class MinimalClient(featurize(*features.LITE)): """ A cut-down, less-featured IRC client. """ ...
(*args, tls_client_cert=None, tls_client_cert_key=None, tls_client_cert_password=None, **kwargs)
42,554
pydle.features.tls
__init__
null
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, *args, tls_client_cert=None, tls_client_cert_key=None, tls_client_cert_password=None, **kwargs)
42,557
pydle.features.rfc1459.client
_create_message
null
def _create_message(self, command, *params, **kwargs): return parsing.RFC1459Message(command, params, **kwargs)
(self, command, *params, **kwargs)
42,560
pydle.features.rfc1459.client
_destroy_user
null
def _destroy_user(self, user, channel=None): if channel: channels = [self.channels[channel]] else: channels = self.channels.values() # Remove user from status list too. for ch in channels: for status in self._nickname_prefixes.values(): if status in ch['modes'] and user in ch['modes'][status]: ch['modes'][status].remove(user)
(self, user, channel=None)
42,568
pydle.features.rfc1459.client
_parse_message
null
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,572
pydle.features.rfc1459.client
_register
Perform IRC connection registration.
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)
42,575
pydle.features.isupport
_reset_attributes
null
def _reset_attributes(self): super()._reset_attributes() self._isupport = {} self._extban_types = [] self._extban_prefix = None
(self)
42,596
pydle.features.rfc1459.client
message
Message channel or user.
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, target, message)
42,598
pydle.features.rfc1459.client
notice
Notice channel or user.
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, target, message)
42,683
pydle.features.rfc1459.client
on_raw_421
Server responded with 'unknown command'.
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,720
pydle.client
NotInChannel
null
class NotInChannel(Error): def __init__(self, channel): super().__init__('Not in channel: {}'.format(channel)) self.channel = channel
(channel)