Skip to content

Commit 959fba5

Browse files
committed
Add isupport checking to check_networks.py, fix irccloud teams check
1 parent adb4f30 commit 959fba5

File tree

5 files changed

+54
-19
lines changed

5 files changed

+54
-19
lines changed

_data/checknetworks.py

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@
4141

4242
class IRCv3Connection:
4343
"""Connects to an IRC server at the given address."""
44-
def __init__(self, hostname, nick, username, realname, ipv6=False, debug=False):
44+
def __init__(self, hostname, nick, username, realname, ipv6=False, debug=False, exit_early=False):
4545
self.debug = debug
46+
self.exit_early = exit_early
4647
self._data = b''
4748

4849
if ipv6:
@@ -61,6 +62,8 @@ def __init__(self, hostname, nick, username, realname, ipv6=False, debug=False):
6162
self.send('CAP LS 302')
6263
self.send('NICK {}'.format(nick))
6364
self.send('USER {} 0 * :{}'.format(username, realname))
65+
if exit_early:
66+
self.send('QUIT')
6467
self.send('CAP END')
6568

6669
# events setup
@@ -74,7 +77,7 @@ def __init__(self, hostname, nick, username, realname, ipv6=False, debug=False):
7477
# basic data
7578
self.caps = {}
7679
self.isupport = {}
77-
80+
7881
def loop(self):
7982
"""Start connection loop."""
8083
try:
@@ -142,38 +145,60 @@ def on_connected(self, msg):
142145
def check_net(versions, info):
143146
print("Connecting to:", info['name'])
144147
hostname = info['net-address']['display']
148+
exit_early = info['net-address'].get('exit-early', False)
145149

146150
supported = {}
147151

148-
irc = IRCv3Connection(hostname, nick, username, realname, debug=False)
152+
irc = IRCv3Connection(hostname, nick, username, realname, debug=False, exit_early=exit_early)
149153
irc.loop()
150154

151-
supported['features'] = irc.isupport.keys()
155+
supported['isupport'] = irc.isupport.keys()
152156
supported['caps'] = irc.caps.keys()
153157

154-
# generate cap lists
158+
# generate cap and isupport lists
155159
all_caps = []
160+
all_isupport = []
156161
for ver in versions:
157162
for spec in versions[ver]['specs']:
158163
all_caps.extend(versions[ver]['specs'][spec].get('caps', []))
159-
160-
claimed_supported = []
161-
for ver in info['support']:
162-
for spec in info['support'][ver]:
163-
claimed_supported.extend(versions[ver]['specs'][spec].get('caps', []))
164-
165-
claimed_unsupported = []
164+
all_isupport.extend(versions[ver]['specs'][spec].get('isupport', []))
165+
166+
claimed_supported_caps = []
167+
claimed_supported_isupport = []
168+
for suptype in ['support', 'partial']:
169+
if suptype not in info:
170+
continue
171+
for ver in info[suptype]:
172+
for spec in info[suptype][ver]:
173+
claimed_supported_caps.extend(versions[ver]['specs'][spec].get('caps', []))
174+
claimed_supported_isupport.extend(versions[ver]['specs'][spec].get('isupport', []))
175+
176+
claimed_unsupported_caps = []
177+
claimed_unsupported_isupport = []
166178
for cap in all_caps:
167-
if cap not in claimed_supported:
168-
claimed_unsupported.append(cap)
179+
if cap not in claimed_supported_caps:
180+
claimed_unsupported_caps.append(cap)
181+
for key in all_isupport:
182+
if key not in claimed_supported_isupport:
183+
claimed_unsupported_isupport.append(key)
169184

170185
# and check them
171-
for cap in claimed_supported:
186+
for cap in claimed_supported_caps:
172187
if cap not in supported['caps']:
173-
print(' *!* - ', info['name'], 'claims to support', cap, 'but does not')
174-
for cap in claimed_unsupported:
188+
print(' *!* - ', info['name'], 'claims to advertise cap', cap, 'but does not')
189+
for cap in claimed_unsupported_caps:
175190
if cap in supported['caps']:
176-
print(' *!* + ', info['name'], 'now also supports', cap)
191+
print(' *!* + ', info['name'], 'now also sadvertise cap', cap)
192+
if exit_early:
193+
# we didn't get to see isupport tokens, skip checking those
194+
return
195+
196+
for token in claimed_supported_isupport:
197+
if token not in supported['isupport']:
198+
print(' *!* - ', info['name'], 'claims to advertise isupport token', token, 'but does not')
199+
for token in claimed_unsupported_isupport:
200+
if token in supported['isupport']:
201+
print(' *!* + ', info['name'], 'now also sadvertise isupport token', token)
177202

178203
if __name__ == '__main__':
179204
arguments = docopt(__doc__, version='0.0.1')

_data/irc_versions.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ stable:
5959
hide-if-no-support: true
6060
tags:
6161
- draft/bot
62+
isupport:
63+
- BOT
6264
chghost:
6365
name: chghost
6466
description: chghost Extension
@@ -106,6 +108,8 @@ stable:
106108
name: Monitor
107109
description: Monitor
108110
link: /specs/extensions/monitor.html
111+
isupport:
112+
- MONITOR
109113
msgid:
110114
name: msgid
111115
description: Message IDs
@@ -167,6 +171,8 @@ stable:
167171
link: /specs/extensions/utf8-only.html
168172
hide-if-no-support: true
169173
hide-on-servers: true
174+
isupport:
175+
- UTF8ONLY
170176
webirc:
171177
name: WebIRC
172178
description: WebIRC Extension

_data/su_networks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
net-address:
4040
link: ircs://team-irc.irccloud.com:6697/
4141
display: team-irc.irccloud.com
42+
exit-early: true
4243
link: https://blog.irccloud.com/private-teams-servers/
4344
note: >
4445
Invite required. PM jwheare for access.

_data/validation/support_list.types.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ support:
4040
tags:
4141
type: listofstrings
4242
required: false
43-
features:
43+
isupport:
4444
type: listofstrings
4545
required: false

_data/validation/sw_list.types.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ software:
3030
type: string
3131
display:
3232
type: string
33+
exit-early:
34+
type: boolean
35+
required: false
3336
os:
3437
type: listofstrings
3538
required: false

0 commit comments

Comments
 (0)