Add new "last" command to crosslink
This commit is contained in:
parent
e31ca4926d
commit
06839ae02b
|
@ -20,6 +20,7 @@ cStatus = {'0': 'T', '1': 'R', '2': 'N'}
|
|||
|
||||
clients = []
|
||||
talking = None
|
||||
lastMessages = []
|
||||
|
||||
class FRNCrosslinkClient(FRNClient):
|
||||
|
||||
|
@ -37,8 +38,15 @@ class FRNCrosslinkClient(FRNClient):
|
|||
else:
|
||||
return client_id
|
||||
|
||||
def sendMultiLineTextMessage(self, client, lines, maxLen=15):
|
||||
chunks = [lines[i*maxLen:(i+1)*maxLen]
|
||||
for i in range((len(lines)+maxLen-1)/maxLen)]
|
||||
for m in chunks:
|
||||
reply = '<br>'.join(m)
|
||||
self.sendTextMessage(client, reply)
|
||||
|
||||
def textMessageReceived(self, client, message, target):
|
||||
global clients
|
||||
global clients, talking, lastMessages
|
||||
if target == 'A':
|
||||
msg = "[%s] %s" % (self.getClientName(client), message)
|
||||
if client != self.clientId:
|
||||
|
@ -52,20 +60,30 @@ class FRNCrosslinkClient(FRNClient):
|
|||
for server, port, u, factory in clients:
|
||||
cl = []
|
||||
cl.append("<u>%s@%s:%d</u>" % (u.NT,server,port))
|
||||
for c in factory.connection.clients:
|
||||
ss = cStatus.get(c['s'], '?')
|
||||
if c['m'] != '0':
|
||||
ss = ss.lower()
|
||||
cl.append(" %s%s %s " % (
|
||||
cType.get(c['bc'], 'G'),
|
||||
ss,
|
||||
c['on'].replace('<', '<'),
|
||||
))
|
||||
sm = [cl[i*15:(i+1)*15]
|
||||
for i in range((len(cl)+14)/15)]
|
||||
for m in sm:
|
||||
reply = '<br>'.join(m)
|
||||
self.sendTextMessage(client, reply)
|
||||
role = factoy.connection.serverdata.get('al', None)
|
||||
if role in ['OK', 'ADMIN', 'OWNER']:
|
||||
for c in factory.connection.clients:
|
||||
ss = cStatus.get(c['s'], '?')
|
||||
if c['m'] != '0':
|
||||
ss = ss.lower()
|
||||
cl.append(" %s%s %s " % (
|
||||
cType.get(c['bc'], 'G'),
|
||||
ss,
|
||||
c['on'].replace('<', '<'),
|
||||
))
|
||||
else:
|
||||
cl.append(" :!: DISCONNECTED :!: ")
|
||||
self.sendMultiLineTextMessage(client, cl)
|
||||
elif cmd == "last":
|
||||
ml = []
|
||||
if talking is not None:
|
||||
ml.append("No client talking now")
|
||||
else:
|
||||
ml.append("%s is talking now" % talking.user.ON)
|
||||
ml.append("Last active talkers (most recent first):")
|
||||
for n in lastMessages:
|
||||
ml.append(n)
|
||||
self.sendMultiLineTextMessage(client, ml)
|
||||
|
||||
def decodeTX(self, my_id):
|
||||
log.msg("Got TX ack for %s" % self.user.ON)
|
||||
|
@ -76,9 +94,12 @@ class FRNCrosslinkClient(FRNClient):
|
|||
log.msg("Stopped TX on %s" % self.user.ON)
|
||||
|
||||
def goIdle(self):
|
||||
global talking
|
||||
global talking, lastMessages
|
||||
self.txReq = False
|
||||
self.txOk = False
|
||||
if talking == self:
|
||||
lastMessages.insert(0, self.user.ON)
|
||||
lastMessages = lastMessages[:5]
|
||||
talking = None
|
||||
self.stopTransmission()
|
||||
|
||||
|
@ -90,7 +111,7 @@ class FRNCrosslinkClient(FRNClient):
|
|||
conn = factory.connection
|
||||
if conn != self:
|
||||
role = conn.serverdata.get('al', None)
|
||||
if role in ['OK', 'ADMIN', 'OWNER']:
|
||||
if role in ['OK', 'ADMIN', 'OWNER']:
|
||||
if conn.txOk:
|
||||
conn.txReq = False
|
||||
conn.sendAudioFrame(frames)
|
||||
|
|
Loading…
Reference in New Issue