Skip to content

Commit 27c60b0

Browse files
committed
Merge remote-tracking branch 'origin/master' into db-changes
# Conflicts: # protocol/Protocol.py
2 parents e4d2723 + a5f3b28 commit 27c60b0

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

Client.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ def Handle(self, data):
123123
flood_limits = self._root.flood_limits[self.access]
124124
else:
125125
flood_limits = self._root.flood_limits['fresh']
126+
126127
#logging.info(" < [" + self.username + " " + str(self.session_id) + "] " + data.strip()) # uncomment for debugging
127128

128129
now = int(time.time())
@@ -213,15 +214,18 @@ def ReportFloodBreach(self, type, bytes):
213214
## send data to client
214215
##
215216
def RealSend(self, data):
216-
## don't append new data to buffer when client gets removed
217217
if not data:
218218
return
219+
220+
raw_msg = data[data.find(" ")+1:] if data.startswith('#') else data
221+
command = raw_msg[:raw_msg.find(" ")] if " " in raw_msg else raw_msg
222+
self._root.outbound_command_stats[command] = self._root.outbound_command_stats.get(command, 0) + 1
223+
219224
#logging.info("> [" + self.username + " " + str(self.session_id) + "] " + data.strip()) # uncomment for debugging
225+
220226
self.transport.write(data.encode("utf-8") + b"\n")
221227

222228
def Send(self, data):
223-
command = data[:data.find(" ")] if " " in data else data
224-
self._root.outbound_command_stats[command] = self._root.outbound_command_stats.get(command, 0) + 1 # ignore when RealSend is used directly
225229
if self.msg_id:
226230
data = self.msg_id + data
227231
if self.buffersend:

DataHandler.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -710,10 +710,10 @@ def createSocket(self):
710710
def stats(self):
711711
logging.info(" -- STATS -- ")
712712
logging.info("Command counts (inbound):")
713-
for k in self.inbound_command_stats:
713+
for k in sorted(self.inbound_command_stats):
714714
logging.info(" %s %d" % (k, self.inbound_command_stats[k]))
715715
logging.info("Command counts (outbound):")
716-
for k in self.outbound_command_stats:
716+
for k in sorted(self.outbound_command_stats):
717717
logging.info(" %s %d" % (k, self.outbound_command_stats[k]))
718718
logging.info("Number of logins: %d" % self.n_login_stats)
719719
logging.info("TLS logins: %d" % self.tls_stats)

protocol/Protocol.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,12 @@ def in_SAYFROM(self, client, chan, location, external_id, msg):
14271427

14281428
# backwards compat
14291429
msg = '<' + bridgedClient.username + '> ' + msg
1430-
self._root.broadcast('SAID %s %s %s' % (chan, client.username, msg), chan, set([]), client, None, 'u')
1430+
if channel.identity=="battle":
1431+
self._root.broadcast('SAIDBATTLE %s %s' % (client.username, msg), chan, set([]), client, None, 'u')
1432+
else:
1433+
self._root.broadcast('SAID %s %s %s' % (chan, client.username, msg), chan, set([]), client, None, 'u')
1434+
if channel.store_history: #fixme for bridged clients
1435+
self.userdb.add_channel_message(channel.id, client.user_id, msg)
14311436

14321437

14331438
def in_IGNORE(self, client, tags):
@@ -1872,7 +1877,7 @@ def in_JOINBATTLEACCEPT(self, client, username):
18721877
return
18731878
if not user.session_id in battle.pending_users:
18741879
return
1875-
self.removePendingBattle(client)
1880+
self.removePendingBattle(user)
18761881
battle.joinBattle(user)
18771882

18781883
def in_JOINBATTLEDENY(self, client, username, reason=None):
@@ -1890,7 +1895,7 @@ def in_JOINBATTLEDENY(self, client, username, reason=None):
18901895
return
18911896
if not user.session_id in battle.pending_users:
18921897
return
1893-
self.removePendingBattle(client)
1898+
self.removePendingBattle(user)
18941899
user.Send('JOINBATTLEFAILED %s%s' % ('Access denied by host', (' ('+reason+')' if reason else '')))
18951900

18961901
def in_KICKFROMBATTLE(self, client, username):
@@ -2396,7 +2401,7 @@ def in_ADDBOT(self, client, name, battlestatus, teamcolor, AIDLL):
23962401
return
23972402

23982403
if name in battle.bots:
2399-
self.out_FAILED(client, "ADDBOT", "Bot already exists!", True)
2404+
self.out_FAILED(client, "ADDBOT", "Bot already exists!", False)
24002405
return
24012406
client.battle_bots[name] = battle.battle_id
24022407
battle.bots[name] = {'owner':client.username, 'battlestatus':battlestatus, 'teamcolor':teamcolor, 'AIDLL':AIDLL}

0 commit comments

Comments
 (0)