.HIDE. General refactoring and documentation

This commit is contained in:
Nyo
2016-11-17 19:13:06 +01:00
parent abad698fe3
commit a2ef03c887
38 changed files with 597 additions and 449 deletions

View File

@@ -1,4 +1,3 @@
""" Contains functions used to read specific client packets from byte stream """
from constants import dataTypes
from helpers import packetHelper
from constants import slotStatuses
@@ -100,7 +99,7 @@ def matchSettings(stream):
start += 2
for i in range(0,16):
s = data[0]["slot{}Status".format(str(i))]
if s != slotStatuses.free and s != slotStatuses.locked:
if s != slotStatuses.FREE and s != slotStatuses.LOCKED:
start += 4
# Other settings

View File

@@ -1,5 +1,3 @@
"""Bancho exceptions"""
# TODO: Prints in exceptions
class loginFailedException(Exception):
pass

View File

@@ -19,12 +19,12 @@ from objects import glob
Commands callbacks
Must have fro, chan and messages as arguments
fro -- name of who triggered the command
chan -- channel where the message was sent
message -- list containing arguments passed from the message
[0] = first argument
[1] = second argument
. . .
:param fro: username of who triggered the command
:param chan: channel"(or username, if PM) where the message was sent
:param message: list containing arguments passed from the message
[0] = first argument
[1] = second argument
. . .
return the message or **False** if there's no response by the bot
TODO: Change False to None, because False doesn't make any sense
@@ -35,6 +35,7 @@ def instantRestart(fro, chan, message):
return False
def faq(fro, chan, message):
# TODO: Unhardcode this
if message[0] == "rules":
return "Please make sure to check (Ripple's rules)[http://ripple.moe/?p=23]."
elif message[0] == "swearing":
@@ -160,11 +161,11 @@ def silence(fro, chan, message):
if unit == 's':
silenceTime = int(amount)
elif unit == 'm':
silenceTime = int(amount)*60
silenceTime = int(amount) * 60
elif unit == 'h':
silenceTime = int(amount)*3600
silenceTime = int(amount) * 3600
elif unit == 'd':
silenceTime = int(amount)*86400
silenceTime = int(amount) * 86400
else:
return "Invalid time unit (s/m/h/d)."
@@ -707,11 +708,6 @@ callback: function to call when the command is triggered. Optional.
response: text to return when the command is triggered. Optional.
syntax: command syntax. Arguments must be separated by spaces (eg: <arg1> <arg2>)
privileges: privileges needed to execute the command. Optional.
NOTES:
- You CAN'T use both rank and minRank at the same time.
- If both rank and minrank are **not** present, everyone will be able to run that command.
- You MUST set trigger and callback/response, or the command won't work.
"""
commands = [
{

View File

@@ -1,2 +1,2 @@
normal = 0
freeMod = 1
NORMAL = 0
FREE_MOD = 1

View File

@@ -1,3 +1,3 @@
score = 0
accuracy = 1
combo = 2
SCORE = 0
ACCURACY = 1
COMBO = 2

View File

@@ -1,4 +1,4 @@
headToHead = 0
tagCoop = 1
teamVs = 2
tagTeamVs = 3
HEAD_TO_HEAD = 0
TAG_COOP = 1
TEAM_VS = 2
TAG_TEAM_VS = 3

View File

@@ -1,3 +1,3 @@
noTeam = 0
blue = 1
red = 2
NO_TEAM = 0
BLUE = 1
RED = 2

View File

@@ -159,7 +159,7 @@ def channelInfo(chan):
return packetHelper.buildPacket(packetIDs.server_channelInfo, [
[chan, dataTypes.STRING],
[channel.description, dataTypes.STRING],
[channel.getConnectedUsersCount(), dataTypes.UINT16]
[len(channel.connectedUsers), dataTypes.UINT16]
])
def channelInfoEnd():

View File

@@ -1,8 +1,8 @@
free = 1
locked = 2
notReady = 4
ready = 8
noMap = 16
playing = 32
occupied = 124
playingQuit = 128
FREE = 1
LOCKED = 2
NOT_READY = 4
READY = 8
NO_MAP = 16
PLAYING = 32
OCCUPIED = 124
PLAYING_QUIT = 128

View File

@@ -1,4 +1,3 @@
"""Bancho user ranks"""
NORMAL = 0
PLAYER = 1
BAT = 2