Skip to content

Commit

Permalink
Improve code style again
Browse files Browse the repository at this point in the history
  • Loading branch information
luk3yx committed Sep 1, 2022
1 parent ed92ddd commit 488c57a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions miniirc.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,10 @@ def _handle_cap(self, cap):
cap = cap.lower()
self.active_caps.add(cap)
if self._unhandled_caps and cap in self._unhandled_caps:
handled = self._handle('IRCv3 ' + cap,
('CAP', 'CAP', 'CAP'), {}, self._unhandled_caps[cap])
handled = self._handle(
'IRCv3 ' + cap, ('CAP', 'CAP', 'CAP'), {},
self._unhandled_caps[cap]
)
if not handled:
self.finish_negotiation(cap)

Expand Down Expand Up @@ -612,7 +614,7 @@ def _handler(irc, hostmask, args):
if not irc.connected:
try:
return int(irc.nick[0])
except:
except ValueError:
pass
if len(irc.nick) >= irc.isupport.get('NICKLEN', 20):
return
Expand All @@ -635,6 +637,7 @@ def _handler(irc, hostmask, args):
if args[-1].startswith('\x01VERSION') and args[-1].endswith('\x01'):
irc.ctcp(hostmask[0], 'VERSION', version, reply=True)


# Handle IRCv3 capabilities
@Handler('CAP', colon=False)
def _handler(irc, hostmask, args):
Expand Down Expand Up @@ -675,6 +678,7 @@ def _handler(irc, hostmask, args):
if cap in irc.active_caps:
irc.active_caps.remove(cap)


# SASL
@Handler('IRCv3 SASL')
def _handler(irc, hostmask, args):
Expand Down Expand Up @@ -707,6 +711,7 @@ def _handler(irc, hostmask, args):
def _handler(irc, hostmask, args):
irc.finish_negotiation('sasl')


# STS
@Handler('IRCv3 STS')
def _handler(irc, hostmask, args):
Expand All @@ -731,6 +736,7 @@ def _handler(irc, hostmask, args):
else:
irc.finish_negotiation('sts')


# Maximum line length
@Handler('IRCv3 oragono.io/maxline-2')
def _handler(irc, hostmask, args):
Expand All @@ -741,6 +747,7 @@ def _handler(irc, hostmask, args):

irc.finish_negotiation(args[0])


# Handle ISUPPORT messages
@Handler('005')
def _handler(irc, hostmask, args):
Expand All @@ -754,7 +761,7 @@ def _handler(irc, hostmask, args):
isupport[key] = int(isupport[key])
if key == 'NICKLEN':
irc.nick = irc.nick[:isupport[key]]
except:
except ValueError:
if key.endswith('LEN'):
remove.add(key)
for key in remove:
Expand Down

0 comments on commit 488c57a

Please sign in to comment.