You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
async def group_send(group_list,msg):
ban_group=[1234]
for id in group_list:
if(id["group_id"] not in ban_group):
await bot.send_group_msg(group_id=id["group_id"],message=msg)
print(msg)
sleep(2)
if(event.message.startswith("群发") and event.user_id==1369727119):
msg=event.message[3:]
try:
group_list=await bot.get_group_list()
threading.Thread(target=lambda:asyncio.run(group_send(group_list,msg))).start()
except Exception as error:
print(error)
如题,如果不使用多线程的话会正常工作,像这样就不行了,实际上不是完全卡死,而是每次消息发送间隔起码一分钟。
I wrote the codes above, I fond that when I use multithreading it can still send messages but the interval of every message is longer than 1 minutes though I set "sleep(2)"(still didn't work when I delete sleep). Could anyone help?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
async def group_send(group_list,msg):
ban_group=[1234]
for id in group_list:
if(id["group_id"] not in ban_group):
await bot.send_group_msg(group_id=id["group_id"],message=msg)
print(msg)
sleep(2)
#_________________________________________________________
#_________________________________________________________
@bot.on_message('private')
async def _(event: Event):
如题,如果不使用多线程的话会正常工作,像这样就不行了,实际上不是完全卡死,而是每次消息发送间隔起码一分钟。
I wrote the codes above, I fond that when I use multithreading it can still send messages but the interval of every message is longer than 1 minutes though I set "sleep(2)"(still didn't work when I delete sleep). Could anyone help?
Beta Was this translation helpful? Give feedback.
All reactions