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 = []
|
clients = []
|
||||||
talking = None
|
talking = None
|
||||||
|
lastMessages = []
|
||||||
|
|
||||||
class FRNCrosslinkClient(FRNClient):
|
class FRNCrosslinkClient(FRNClient):
|
||||||
|
|
||||||
|
@ -37,8 +38,15 @@ class FRNCrosslinkClient(FRNClient):
|
||||||
else:
|
else:
|
||||||
return client_id
|
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):
|
def textMessageReceived(self, client, message, target):
|
||||||
global clients
|
global clients, talking, lastMessages
|
||||||
if target == 'A':
|
if target == 'A':
|
||||||
msg = "[%s] %s" % (self.getClientName(client), message)
|
msg = "[%s] %s" % (self.getClientName(client), message)
|
||||||
if client != self.clientId:
|
if client != self.clientId:
|
||||||
|
@ -52,20 +60,30 @@ class FRNCrosslinkClient(FRNClient):
|
||||||
for server, port, u, factory in clients:
|
for server, port, u, factory in clients:
|
||||||
cl = []
|
cl = []
|
||||||
cl.append("<u>%s@%s:%d</u>" % (u.NT,server,port))
|
cl.append("<u>%s@%s:%d</u>" % (u.NT,server,port))
|
||||||
for c in factory.connection.clients:
|
role = factoy.connection.serverdata.get('al', None)
|
||||||
ss = cStatus.get(c['s'], '?')
|
if role in ['OK', 'ADMIN', 'OWNER']:
|
||||||
if c['m'] != '0':
|
for c in factory.connection.clients:
|
||||||
ss = ss.lower()
|
ss = cStatus.get(c['s'], '?')
|
||||||
cl.append(" %s%s %s " % (
|
if c['m'] != '0':
|
||||||
cType.get(c['bc'], 'G'),
|
ss = ss.lower()
|
||||||
ss,
|
cl.append(" %s%s %s " % (
|
||||||
c['on'].replace('<', '<'),
|
cType.get(c['bc'], 'G'),
|
||||||
))
|
ss,
|
||||||
sm = [cl[i*15:(i+1)*15]
|
c['on'].replace('<', '<'),
|
||||||
for i in range((len(cl)+14)/15)]
|
))
|
||||||
for m in sm:
|
else:
|
||||||
reply = '<br>'.join(m)
|
cl.append(" :!: DISCONNECTED :!: ")
|
||||||
self.sendTextMessage(client, reply)
|
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):
|
def decodeTX(self, my_id):
|
||||||
log.msg("Got TX ack for %s" % self.user.ON)
|
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)
|
log.msg("Stopped TX on %s" % self.user.ON)
|
||||||
|
|
||||||
def goIdle(self):
|
def goIdle(self):
|
||||||
global talking
|
global talking, lastMessages
|
||||||
self.txReq = False
|
self.txReq = False
|
||||||
self.txOk = False
|
self.txOk = False
|
||||||
|
if talking == self:
|
||||||
|
lastMessages.insert(0, self.user.ON)
|
||||||
|
lastMessages = lastMessages[:5]
|
||||||
talking = None
|
talking = None
|
||||||
self.stopTransmission()
|
self.stopTransmission()
|
||||||
|
|
||||||
|
@ -90,7 +111,7 @@ class FRNCrosslinkClient(FRNClient):
|
||||||
conn = factory.connection
|
conn = factory.connection
|
||||||
if conn != self:
|
if conn != self:
|
||||||
role = conn.serverdata.get('al', None)
|
role = conn.serverdata.get('al', None)
|
||||||
if role in ['OK', 'ADMIN', 'OWNER']:
|
if role in ['OK', 'ADMIN', 'OWNER']:
|
||||||
if conn.txOk:
|
if conn.txOk:
|
||||||
conn.txReq = False
|
conn.txReq = False
|
||||||
conn.sendAudioFrame(frames)
|
conn.sendAudioFrame(frames)
|
||||||
|
|
Loading…
Reference in New Issue