Skip to content

Commit f11de04

Browse files
committed
Add delay between channel joins and make joins async
1 parent be6074c commit f11de04

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

plugins/autojoin.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import asyncio
2+
13
from sqlalchemy import PrimaryKeyConstraint, Column, String, Table, and_
24
from sqlalchemy.exc import IntegrityError
35

@@ -13,11 +15,17 @@
1315
)
1416

1517

18+
def get_channels(db, conn):
19+
return db.execute(table.select().where(table.c.conn == conn.name.casefold())).fetchall()
20+
21+
22+
@asyncio.coroutine
1623
@hook.irc_raw('004')
17-
def do_joins(db, conn):
18-
chans = db.execute(table.select().where(table.c.conn == conn.name.casefold())).fetchall()
24+
def do_joins(db, conn, async):
25+
chans = async(get_channels, db, conn)
1926
for chan in chans:
2027
conn.join(chan[1])
28+
yield from asyncio.sleep(0.4)
2129

2230

2331
@hook.irc_raw('JOIN', singlethread=True)

0 commit comments

Comments
 (0)