Add thread when doing long tasks
This commit is contained in:
parent
f676ce11c6
commit
69c5d06ed7
|
@ -62,8 +62,8 @@ class Credits:
|
||||||
now = datetime.now() + self.randsec
|
now = datetime.now() + self.randsec
|
||||||
if self.lastmessage.minute == now.minute and (self.lastmessage.second == now.second or self.lastmessage.second == now.second - 1):
|
if self.lastmessage.minute == now.minute and (self.lastmessage.second == now.second or self.lastmessage.second == now.second - 1):
|
||||||
print("AUTOBAN %s: too low time between messages" % self.name)
|
print("AUTOBAN %s: too low time between messages" % self.name)
|
||||||
BANLIST.append(self.name)
|
#BANLIST.append(self.name)
|
||||||
#self.credits -= self.credits / 2 #Une alternative
|
self.credits -= self.credits / 2 #Une alternative
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.iask = True
|
self.iask = True
|
||||||
|
@ -169,6 +169,10 @@ class Message:
|
||||||
self.cmd = "UNKNOWN"
|
self.cmd = "UNKNOWN"
|
||||||
print (line)
|
print (line)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_owner(self):
|
||||||
|
return self.sender == self.srv.owner
|
||||||
|
|
||||||
|
|
||||||
def send_msg (self, channel, msg, cmd = "PRIVMSG", endl = "\r\n"):
|
def send_msg (self, channel, msg, cmd = "PRIVMSG", endl = "\r\n"):
|
||||||
if CREDITS[self.realname].speak():
|
if CREDITS[self.realname].speak():
|
||||||
|
|
38
nemuspeak.py
38
nemuspeak.py
|
@ -164,6 +164,7 @@ class Server:
|
||||||
return msg.sender != OWNER and (msg.channel == OWNER or msg.channel in self.channels)
|
return msg.sender != OWNER and (msg.channel == OWNER or msg.channel in self.channels)
|
||||||
|
|
||||||
def read(self):
|
def read(self):
|
||||||
|
global stopSpk, talkEC, g_queue
|
||||||
readbuffer = "" #Here we store all the messages from server
|
readbuffer = "" #Here we store all the messages from server
|
||||||
while 1:
|
while 1:
|
||||||
try:
|
try:
|
||||||
|
@ -178,10 +179,39 @@ class Server:
|
||||||
msg = message.Message(self, line)
|
msg = message.Message(self, line)
|
||||||
if msg.cmd == "PING":
|
if msg.cmd == "PING":
|
||||||
self.s.send(("PONG %s\r\n" % msg.content).encode ())
|
self.s.send(("PONG %s\r\n" % msg.content).encode ())
|
||||||
elif msg.cmd == "PRIVMSG" and self.authorize(msg):
|
elif msg.cmd == "PRIVMSG" and (self.authorize(msg) or msg.content[0] == '`'):
|
||||||
g_queue.append(msg)
|
if msg.content[0] == '`' and msg.sender == OWNER:
|
||||||
if talkEC == 0:
|
cmd = msg.content[1:].split(' ')
|
||||||
_thread.start_new_thread(speak, (0,))
|
if cmd[0] == "speak":
|
||||||
|
_thread.start_new_thread(speak, (0,))
|
||||||
|
elif cmd[0] == 'reset':
|
||||||
|
while len(g_queue) > 0:
|
||||||
|
g_queue.pop()
|
||||||
|
elif cmd[0] == 'save':
|
||||||
|
if talkEC == 0:
|
||||||
|
talkEC = 1
|
||||||
|
stopSpk = 1
|
||||||
|
elif cmd[0] == 'test':
|
||||||
|
g_queue.append(message.Message(self, ":Quelqun!someone@p0m.fr PRIVMSG %s :Ceci est un message de test ;)"%(self.channels)))
|
||||||
|
elif cmd[0] == 'list':
|
||||||
|
print ("Currently listened channels:")
|
||||||
|
for chan in self.channels:
|
||||||
|
print (chan)
|
||||||
|
print ("-- ")
|
||||||
|
elif cmd[0] == 'add' and len(cmd) > 1:
|
||||||
|
self.channels.append(cmd[1])
|
||||||
|
print (cmd[1] + " added to listened channels")
|
||||||
|
elif cmd[0] == 'del' and len(cmd) > 1:
|
||||||
|
if self.channels.count(cmd[1]) > 0:
|
||||||
|
self.channels.remove(cmd[1])
|
||||||
|
print (cmd[1] + " removed from listened channels")
|
||||||
|
else:
|
||||||
|
print (cmd[1] + " not in listened channels")
|
||||||
|
|
||||||
|
else:
|
||||||
|
g_queue.append(msg)
|
||||||
|
if talkEC == 0:
|
||||||
|
_thread.start_new_thread(speak, (0,))
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
self.s = socket.socket( ) #Create the socket
|
self.s = socket.socket( ) #Create the socket
|
||||||
|
|
28
qd.py
28
qd.py
|
@ -41,6 +41,16 @@ class Score:
|
||||||
self.great = int(item.getAttribute("great"))
|
self.great = int(item.getAttribute("great"))
|
||||||
self.bad = int(item.getAttribute("bad"))
|
self.bad = int(item.getAttribute("bad"))
|
||||||
|
|
||||||
|
def merge(self, other):
|
||||||
|
self.ftt += other.ftt
|
||||||
|
self.twt += other.twt
|
||||||
|
self.pi += other.pi
|
||||||
|
self.notfound += other.notfound
|
||||||
|
self.tententen += other.tententen
|
||||||
|
self.leet += other.leet
|
||||||
|
self.great += other.great
|
||||||
|
self.bad += other.bad
|
||||||
|
|
||||||
def newWinner(self):
|
def newWinner(self):
|
||||||
self.ftt = 0
|
self.ftt = 0
|
||||||
self.twt = 0
|
self.twt = 0
|
||||||
|
@ -164,7 +174,17 @@ def rev (tupl):
|
||||||
def parseanswer (msg):
|
def parseanswer (msg):
|
||||||
if msg.cmd[0] == "42" or msg.cmd[0] == "score" or msg.cmd[0] == "scores":
|
if msg.cmd[0] == "42" or msg.cmd[0] == "score" or msg.cmd[0] == "scores":
|
||||||
global SCORES, MANCHE
|
global SCORES, MANCHE
|
||||||
if len(msg.cmd) > 1 and (msg.cmd[1] == "help" or msg.cmd[1] == "aide"):
|
if len(msg.cmd) > 3 and msg.is_owner and (msg.cmd[1] == "merge"):
|
||||||
|
if msg.cmd[2] in SCORES and msg.cmd[3] in SCORES:
|
||||||
|
SCORES[msg.cmd[2]].merge (SCORES[msg.cmd[3]])
|
||||||
|
del SCORES[msg.cmd[3]]
|
||||||
|
msg.send_chn ("%s a été correctement fusionné avec %s."%(msg.cmd[3], msg.cmd[2]))
|
||||||
|
else:
|
||||||
|
if msg.cmd[2] not in SCORES:
|
||||||
|
msg.send_chn ("%s n'est pas un joueur connu."%msg.cmd[2])
|
||||||
|
elif msg.cmd[3] not in SCORES:
|
||||||
|
msg.send_chn ("%s n'est pas un joueur connu."%msg.cmd[3])
|
||||||
|
elif len(msg.cmd) > 1 and (msg.cmd[1] == "help" or msg.cmd[1] == "aide"):
|
||||||
msg.send_chn ("Formule : normal * 2 - bad * 10 + great * 5 + leet * 3 + pi * 3.1415 + dt + not_found * 4.04")
|
msg.send_chn ("Formule : normal * 2 - bad * 10 + great * 5 + leet * 3 + pi * 3.1415 + dt + not_found * 4.04")
|
||||||
elif len(msg.cmd) > 1 and (msg.cmd[1] == "manche" or msg.cmd[1] == "round"):
|
elif len(msg.cmd) > 1 and (msg.cmd[1] == "manche" or msg.cmd[1] == "round"):
|
||||||
msg.send_chn ("Nous sommes dans la %de manche, gagnée par %s avec %d points et commencée par %s le %s"%MANCHE)
|
msg.send_chn ("Nous sommes dans la %de manche, gagnée par %s avec %d points et commencée par %s le %s"%MANCHE)
|
||||||
|
@ -173,8 +193,8 @@ def parseanswer (msg):
|
||||||
phrase = ""
|
phrase = ""
|
||||||
|
|
||||||
if len(msg.cmd) > 1:
|
if len(msg.cmd) > 1:
|
||||||
if msg.cmd[1].lower() in SCORES:
|
if msg.cmd[1] in SCORES:
|
||||||
phrase += " " + msg.cmd[1] + ": " + SCORES[msg.cmd[1].lower()].details()
|
phrase += " " + msg.cmd[1] + ": " + SCORES[msg.cmd[1]].details()
|
||||||
else:
|
else:
|
||||||
phrase = " %s n'a encore jamais joué,"%(msg.cmd[1])
|
phrase = " %s n'a encore jamais joué,"%(msg.cmd[1])
|
||||||
else:
|
else:
|
||||||
|
@ -194,7 +214,7 @@ def parseanswer (msg):
|
||||||
|
|
||||||
def win(msg):
|
def win(msg):
|
||||||
global SCORES, MANCHE
|
global SCORES, MANCHE
|
||||||
who = msg.sender.lower()
|
who = msg.sender
|
||||||
|
|
||||||
(num_manche, winner, nb_points, whosef, dayte) = MANCHE
|
(num_manche, winner, nb_points, whosef, dayte) = MANCHE
|
||||||
|
|
||||||
|
|
135
soutenance.py
135
soutenance.py
|
@ -3,6 +3,7 @@
|
||||||
import http.client
|
import http.client
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
|
import _thread
|
||||||
from datetime import date
|
from datetime import date
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
@ -124,73 +125,87 @@ def help_full ():
|
||||||
return "!soutenance: gives information about current defenses state\n!soutenance /who/: gives the date of the next defense of /who/.\n!soutenances /who/: gives all defense dates of /who/"
|
return "!soutenance: gives information about current defenses state\n!soutenance /who/: gives the date of the next defense of /who/.\n!soutenances /who/: gives all defense dates of /who/"
|
||||||
|
|
||||||
datas = None
|
datas = None
|
||||||
|
THREAD = None
|
||||||
|
wait = list()
|
||||||
|
|
||||||
def parseanswer (msg):
|
def parseanswer (msg):
|
||||||
global datas
|
global THREAD, wait
|
||||||
if msg.cmd[0] == "soutenance" or msg.cmd[0] == "soutenances":
|
if msg.cmd[0] == "soutenance" or msg.cmd[0] == "soutenances":
|
||||||
#Starts by updating datas
|
if THREAD is None:
|
||||||
if datas is not None:
|
THREAD = _thread.start_new_thread (startSoutenance, (msg,))
|
||||||
datas = datas.update ()
|
|
||||||
if datas is None:
|
|
||||||
datas = SiteSoutenances(getPage().decode())
|
|
||||||
|
|
||||||
if len(msg.cmd) == 1 or msg.cmd[1] == "next":
|
|
||||||
soutenance = datas.findLast()
|
|
||||||
if soutenance is None:
|
|
||||||
msg.send_chn ("Il ne semble pas y avoir de soutenance pour le moment.")
|
|
||||||
else:
|
|
||||||
if soutenance.start > soutenance.hour:
|
|
||||||
avre = "%s de *retard*"%msg.just_countdown(soutenance.start - soutenance.hour, 4)
|
|
||||||
else:
|
|
||||||
avre = "%s *d'avance*"%msg.just_countdown(soutenance.hour - soutenance.start, 4)
|
|
||||||
msg.send_chn ("Actuellement à la soutenance numéro %d, commencée il y a %s avec %s."%(soutenance.rank, msg.just_countdown(datetime.now () - soutenance.start, 4), avre))
|
|
||||||
|
|
||||||
elif msg.cmd[1] == "assistants" or msg.cmd[1] == "assistant" or msg.cmd[1] == "yaka" or msg.cmd[1] == "yakas" or msg.cmd[1] == "acu" or msg.cmd[1] == "acus":
|
|
||||||
assistants = datas.findAssistants()
|
|
||||||
if len(assistants) > 0:
|
|
||||||
msg.send_chn ("Les %d assistants faisant passer les soutenances sont : %s." % (len(assistants), ', '.join(assistants.keys())))
|
|
||||||
else:
|
|
||||||
msg.send_chn ("Il ne semble pas y avoir de soutenance pour le moment.")
|
|
||||||
else:
|
else:
|
||||||
name = msg.cmd[1]
|
wait.append(msg)
|
||||||
|
|
||||||
if msg.cmd[0] == "soutenance":
|
|
||||||
soutenance = datas.findClose(name)
|
|
||||||
if soutenance is None:
|
|
||||||
msg.send_chn ("Pas d'horaire de soutenance pour %s."%name)
|
|
||||||
else:
|
|
||||||
if soutenance.state == "En cours":
|
|
||||||
msg.send_chn ("%s est actuellement en soutenance avec %s. Elle était prévue à %s, position %d."%(name, soutenance.assistant, soutenance.hour, soutenance.rank))
|
|
||||||
elif soutenance.state == "Effectue":
|
|
||||||
msg.send_chn ("%s a passé sa soutenance avec %s. Elle a duré %s."%(name, soutenance.assistant, msg.just_countdown(soutenance.end - soutenance.start, 4)))
|
|
||||||
elif soutenance.state == "Retard":
|
|
||||||
msg.send_chn ("%s était en retard à sa soutenance de %s."%(name, soutenance.hour))
|
|
||||||
else:
|
|
||||||
last = datas.findLast()
|
|
||||||
if last is not None:
|
|
||||||
if soutenance.hour + (last.start - last.hour) > datetime.now ():
|
|
||||||
msg.send_chn ("Soutenance de %s : %s, position %d ; estimation du passage : dans %s."%(name, soutenance.hour, soutenance.rank, msg.just_countdown((soutenance.hour - datetime.now ()) + (last.start - last.hour))))
|
|
||||||
else:
|
|
||||||
msg.send_chn ("Soutenance de %s : %s, position %d ; passage imminent."%(name, soutenance.hour, soutenance.rank))
|
|
||||||
else:
|
|
||||||
msg.send_chn ("Soutenance de %s : %s, position %d."%(name, soutenance.hour, soutenance.rank))
|
|
||||||
|
|
||||||
elif msg.cmd[0] == "soutenances":
|
|
||||||
souts = datas.findAll(name)
|
|
||||||
if souts is None:
|
|
||||||
msg.send_snd ("Pas de soutenance prévues pour %s."%name)
|
|
||||||
else:
|
|
||||||
first = True
|
|
||||||
for s in souts:
|
|
||||||
if first:
|
|
||||||
msg.send_snd ("Soutenance(s) de %s : - %s (position %d) ;"%(name, s.hour, s.rank))
|
|
||||||
first = False
|
|
||||||
else:
|
|
||||||
msg.send_snd (" %s - %s (position %d) ;"%(len(name)*' ', s.hour, s.rank))
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def startSoutenance (msg):
|
||||||
|
global datas, THREAD, wait
|
||||||
|
|
||||||
|
#Starts by updating datas
|
||||||
|
if datas is not None:
|
||||||
|
datas = datas.update ()
|
||||||
|
if datas is None:
|
||||||
|
datas = SiteSoutenances(getPage().decode())
|
||||||
|
|
||||||
|
if len(msg.cmd) == 1 or msg.cmd[1] == "next":
|
||||||
|
soutenance = datas.findLast()
|
||||||
|
if soutenance is None:
|
||||||
|
msg.send_chn ("Il ne semble pas y avoir de soutenance pour le moment.")
|
||||||
|
else:
|
||||||
|
if soutenance.start > soutenance.hour:
|
||||||
|
avre = "%s de *retard*"%msg.just_countdown(soutenance.start - soutenance.hour, 4)
|
||||||
|
else:
|
||||||
|
avre = "%s *d'avance*"%msg.just_countdown(soutenance.hour - soutenance.start, 4)
|
||||||
|
msg.send_chn ("Actuellement à la soutenance numéro %d, commencée il y a %s avec %s."%(soutenance.rank, msg.just_countdown(datetime.now () - soutenance.start, 4), avre))
|
||||||
|
|
||||||
|
elif msg.cmd[1] == "assistants" or msg.cmd[1] == "assistant" or msg.cmd[1] == "yaka" or msg.cmd[1] == "yakas" or msg.cmd[1] == "acu" or msg.cmd[1] == "acus":
|
||||||
|
assistants = datas.findAssistants()
|
||||||
|
if len(assistants) > 0:
|
||||||
|
msg.send_chn ("Les %d assistants faisant passer les soutenances sont : %s." % (len(assistants), ', '.join(assistants.keys())))
|
||||||
|
else:
|
||||||
|
msg.send_chn ("Il ne semble pas y avoir de soutenance pour le moment.")
|
||||||
|
else:
|
||||||
|
name = msg.cmd[1]
|
||||||
|
|
||||||
|
if msg.cmd[0] == "soutenance":
|
||||||
|
soutenance = datas.findClose(name)
|
||||||
|
if soutenance is None:
|
||||||
|
msg.send_chn ("Pas d'horaire de soutenance pour %s."%name)
|
||||||
|
else:
|
||||||
|
if soutenance.state == "En cours":
|
||||||
|
msg.send_chn ("%s est actuellement en soutenance avec %s. Elle était prévue à %s, position %d."%(name, soutenance.assistant, soutenance.hour, soutenance.rank))
|
||||||
|
elif soutenance.state == "Effectue":
|
||||||
|
msg.send_chn ("%s a passé sa soutenance avec %s. Elle a duré %s."%(name, soutenance.assistant, msg.just_countdown(soutenance.end - soutenance.start, 4)))
|
||||||
|
elif soutenance.state == "Retard":
|
||||||
|
msg.send_chn ("%s était en retard à sa soutenance de %s."%(name, soutenance.hour))
|
||||||
|
else:
|
||||||
|
last = datas.findLast()
|
||||||
|
if last is not None:
|
||||||
|
if soutenance.hour + (last.start - last.hour) > datetime.now ():
|
||||||
|
msg.send_chn ("Soutenance de %s : %s, position %d ; estimation du passage : dans %s."%(name, soutenance.hour, soutenance.rank, msg.just_countdown((soutenance.hour - datetime.now ()) + (last.start - last.hour))))
|
||||||
|
else:
|
||||||
|
msg.send_chn ("Soutenance de %s : %s, position %d ; passage imminent."%(name, soutenance.hour, soutenance.rank))
|
||||||
|
else:
|
||||||
|
msg.send_chn ("Soutenance de %s : %s, position %d."%(name, soutenance.hour, soutenance.rank))
|
||||||
|
|
||||||
|
elif msg.cmd[0] == "soutenances":
|
||||||
|
souts = datas.findAll(name)
|
||||||
|
if souts is None:
|
||||||
|
msg.send_snd ("Pas de soutenance prévues pour %s."%name)
|
||||||
|
else:
|
||||||
|
first = True
|
||||||
|
for s in souts:
|
||||||
|
if first:
|
||||||
|
msg.send_snd ("Soutenance(s) de %s : - %s (position %d) ;"%(name, s.hour, s.rank))
|
||||||
|
first = False
|
||||||
|
else:
|
||||||
|
msg.send_snd (" %s - %s (position %d) ;"%(len(name)*' ', s.hour, s.rank))
|
||||||
|
THREAD = None
|
||||||
|
if len(wait) > 0:
|
||||||
|
startSoutenance(wait.pop())
|
||||||
|
|
||||||
|
|
||||||
def parseask (msg):
|
def parseask (msg):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
110
whereis.py
110
whereis.py
|
@ -4,6 +4,7 @@ import re
|
||||||
import sys
|
import sys
|
||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
|
import _thread
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from datetime import date
|
from datetime import date
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
@ -15,15 +16,19 @@ from xml.dom.minidom import getDOMImplementation
|
||||||
NS_SERVER = 'ns-server.epita.fr'
|
NS_SERVER = 'ns-server.epita.fr'
|
||||||
NS_PORT = 4242
|
NS_PORT = 4242
|
||||||
|
|
||||||
|
THREAD = None
|
||||||
|
search = list()
|
||||||
|
|
||||||
class UpdatedStorage:
|
class UpdatedStorage:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
sock = connect_to_ns(NS_SERVER, NS_PORT)
|
sock = connect_to_ns(NS_SERVER, NS_PORT)
|
||||||
self.users = dict()
|
self.users = dict()
|
||||||
for l in list_users(sock):
|
if sock != None:
|
||||||
u = User(l)
|
for l in list_users(sock):
|
||||||
self.users[u.login] = u
|
u = User(l)
|
||||||
sock.close()
|
self.users[u.login] = u
|
||||||
self.lastUpdate = datetime.now ()
|
sock.close()
|
||||||
|
self.lastUpdate = datetime.now ()
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
if datetime.now () - self.lastUpdate < timedelta(minutes=10):
|
if datetime.now () - self.lastUpdate < timedelta(minutes=10):
|
||||||
|
@ -52,6 +57,8 @@ class User(object):
|
||||||
return 'en midlab'
|
return 'en midlab'
|
||||||
elif self.ip.startswith('10.250'):
|
elif self.ip.startswith('10.250'):
|
||||||
return 'en cisco'
|
return 'en cisco'
|
||||||
|
elif self.ip.startswith('10.41'):
|
||||||
|
return 'sur le wifi'
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -63,7 +70,10 @@ class User(object):
|
||||||
else:
|
else:
|
||||||
return "chez lui"
|
return "chez lui"
|
||||||
else:
|
else:
|
||||||
return self.sm + " rangée " + self.ip.split('.')[2] + " poste " + self.ip.split('.')[3]
|
if self.ip.startswith('10.200'):
|
||||||
|
return self.sm + " poste " + self.ip.split('.')[3]
|
||||||
|
else:
|
||||||
|
return self.sm + " rangée " + self.ip.split('.')[2] + " poste " + self.ip.split('.')[3]
|
||||||
|
|
||||||
def __cmp__(self, other):
|
def __cmp__(self, other):
|
||||||
return cmp(self.login, other.login)
|
return cmp(self.login, other.login)
|
||||||
|
@ -72,10 +82,14 @@ class User(object):
|
||||||
return hash(self.login)
|
return hash(self.login)
|
||||||
|
|
||||||
def connect_to_ns(server, port):
|
def connect_to_ns(server, port):
|
||||||
|
try:
|
||||||
s = socket.socket()
|
s = socket.socket()
|
||||||
|
s.settimeout(1)
|
||||||
s.connect((server, port))
|
s.connect((server, port))
|
||||||
s.recv(8192) # salut ...
|
except socket.error:
|
||||||
return s
|
return None
|
||||||
|
s.recv(8192) # salut ...
|
||||||
|
return s
|
||||||
|
|
||||||
def list_users(sock):
|
def list_users(sock):
|
||||||
sock.send('list_users\n'.encode())
|
sock.send('list_users\n'.encode())
|
||||||
|
@ -94,6 +108,8 @@ def load_module(datas_path):
|
||||||
|
|
||||||
def save_module():
|
def save_module():
|
||||||
"""Save the module state"""
|
"""Save the module state"""
|
||||||
|
if THREAD is not None:
|
||||||
|
THREAD.exit()
|
||||||
return
|
return
|
||||||
|
|
||||||
def help_tiny ():
|
def help_tiny ():
|
||||||
|
@ -105,48 +121,54 @@ def help_full ():
|
||||||
|
|
||||||
datas = None
|
datas = None
|
||||||
|
|
||||||
def parseanswer (msg):
|
def startWhereis(msg):
|
||||||
global datas
|
global datas, THREAD, search
|
||||||
if msg.cmd[0] == "whereis" or msg.cmd[0] == "whereare" or msg.cmd[0] == "ouest" or msg.cmd[0] == "ousont":
|
if datas is not None:
|
||||||
if datas is not None:
|
datas = datas.update ()
|
||||||
datas = datas.update ()
|
if datas is None:
|
||||||
if datas is None:
|
datas = UpdatedStorage()
|
||||||
datas = UpdatedStorage()
|
if datas is None:
|
||||||
|
msg.send_chn("Hmm c'est embarassant, serait-ce la fin du monde ou juste netsoul qui est mort ?")
|
||||||
|
return
|
||||||
|
|
||||||
|
pasla = list()
|
||||||
|
|
||||||
|
for name in msg.cmd:
|
||||||
|
if name == "whereis" or name == "whereare" or name == "ouest" or name == "ousont" or name == "ip":
|
||||||
|
if len(msg.cmd) >= 2:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
name = msg.sender
|
||||||
|
|
||||||
|
if name in datas.users:
|
||||||
|
if msg.cmd[0] == "ip":
|
||||||
|
msg.send_chn ("L'ip de %s est %s." %(name, datas.users[name].ip))
|
||||||
|
else:
|
||||||
|
msg.send_chn ("%s est %s (%s)." %(name, datas.users[name].poste, unquote(datas.users[name].location)))
|
||||||
|
else:
|
||||||
|
pasla.append(name)
|
||||||
|
|
||||||
|
if len(pasla) == 1:
|
||||||
|
msg.send_chn ("%s n'est pas connecté sur le PIE." % pasla[0])
|
||||||
|
elif len(pasla) > 1:
|
||||||
|
msg.send_chn ("%s ne sont pas connectés sur le PIE." % ", ".join(pasla))
|
||||||
|
|
||||||
|
THREAD = None
|
||||||
|
if len(search) > 0:
|
||||||
|
startWhereis(search.pop())
|
||||||
|
|
||||||
|
|
||||||
|
def parseanswer (msg):
|
||||||
|
global datas, THREAD, search
|
||||||
|
if msg.cmd[0] == "whereis" or msg.cmd[0] == "whereare" or msg.cmd[0] == "ouest" or msg.cmd[0] == "ousont" or msg.cmd[0] == "ip":
|
||||||
if len(msg.cmd) > 10:
|
if len(msg.cmd) > 10:
|
||||||
msg.send_snd ("Demande moi moins de personnes à la fois dans ton !%s" % msg.cmd[0])
|
msg.send_snd ("Demande moi moins de personnes à la fois dans ton !%s" % msg.cmd[0])
|
||||||
return True
|
return True
|
||||||
|
|
||||||
pasla = list()
|
if THREAD is None:
|
||||||
|
THREAD = _thread.start_new_thread (startWhereis, (msg,))
|
||||||
for name in msg.cmd:
|
|
||||||
if name == "whereis" or name == "whereare" or name == "ouest" or name == "ousont":
|
|
||||||
if len(msg.cmd) >= 2:
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
name = msg.sender
|
|
||||||
|
|
||||||
if name in datas.users:
|
|
||||||
msg.send_chn ("%s est %s (%s)." %(name, datas.users[name].poste, unquote(datas.users[name].location)))
|
|
||||||
else:
|
|
||||||
pasla.append(name)
|
|
||||||
|
|
||||||
if len(pasla) == 1:
|
|
||||||
msg.send_chn ("%s n'est pas connecté sur le PIE." % pasla[0])
|
|
||||||
elif len(pasla) > 1:
|
|
||||||
msg.send_chn ("%s ne sont pas connectés sur le PIE." % ", ".join(pasla))
|
|
||||||
|
|
||||||
return True
|
|
||||||
elif msg.cmd[0] == "ip":
|
|
||||||
if len(msg.cmd) >= 2:
|
|
||||||
name = msg.cmd[1]
|
|
||||||
else:
|
else:
|
||||||
name = msg.sender
|
search.append(msg)
|
||||||
|
|
||||||
if name in datas.users:
|
|
||||||
msg.send_chn ("L'ip de %s est %s." %(name, datas.users[name].ip))
|
|
||||||
else:
|
|
||||||
msg.send_chn ("%s n'est pas connecté à netsoul." % name)
|
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user