small problem with my code 05-16-2014, 07:20 PM
#1
Hi all.
I have my own jabber bot and today i make new plugin which is to send message for all users. my code was working good but i have small problem thats when i give my bot command to send message my bot get stuck and disconected.
I know my bot get stuck and disconected because i have more than 2000 users so my bot can not send MSG in the same time for all users.
now i need to ask you if there are any method by python to make my code send the MSG for each user after N second i mean bot send MSG for user1 then wait for N second and send for user2 and like that...
Hope my idea is clear and this is my code.
I have my own jabber bot and today i make new plugin which is to send message for all users. my code was working good but i have small problem thats when i give my bot command to send message my bot get stuck and disconected.
I know my bot get stuck and disconected because i have more than 2000 users so my bot can not send MSG in the same time for all users.
now i need to ask you if there are any method by python to make my code send the MSG for each user after N second i mean bot send MSG for user1 then wait for N second and send for user2 and like that...
Hope my idea is clear and this is my code.
Code:
def send_msg(type, source, parameters):
ADMINFILE = 'modules/xmpp/users.cfg'
fp = open(ADMINFILE, 'r')
users = eval(fp.read())
if parameters:
for z in users:
msg(z, u"MSG from Admin:\n" +parameters)
reply(type, source, u"MSG has been sent!")
else:
reply(type, source, u"Error! please try again.")
register_command_handler(send_msg, 'msg', ['all','amsg'], 0,'Sends a message to all users')

![[+]](https://sinister.li/images/modern/collapse_collapsed.png)


