Skip to content

Commit

Permalink
add cap_negotiated event
Browse files Browse the repository at this point in the history
  • Loading branch information
abra3607 authored and tuzonghua committed Nov 21, 2017
1 parent 8abe5fb commit 9a3df97
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions plugins/cap.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ def on_connect(bot, conn):
:type bot: CloudBot
:type conn: IrcClient
"""
m = conn.memory
if 'CAP_lock' not in m:
m['CAP_lock'] = asyncio.Lock()
if 'CAP_negotiated' not in m:
m['CAP_negotiated'] = asyncio.Event()

if not conn.capabilities:
return

while not conn.ready:
yield from asyncio.sleep(3)

m = conn.memory
if 'CAP_lock' not in m:
m['CAP_lock'] = asyncio.Lock()

with (yield from m['CAP_lock']):
m['CAP_LS_future'] = asyncio.Future()
conn.send('CAP LS')
Expand Down Expand Up @@ -50,6 +51,7 @@ def on_connect(bot, conn):
bot.logger.info('[{}|CAP] Successfully negotiated for: {}'.format(conn.name, accepted))

conn.send('CAP END')
m['CAP_negotiated'].set()


@asyncio.coroutine
Expand Down

0 comments on commit 9a3df97

Please sign in to comment.