def handleMsg(self, connection, cmd, msg): if(cmd == 30 and connection.authLevel > 0): # send chat log(self, "relaying chat from from %s to skype: %s" % (connection, msg[2:]), 2) self.chat.SendMessage(msg[2:]) return # break here so that we don't get echo # messages that we don't handle get passed to the usual handler CC_Server.handleMsg(self, connection, cmd, msg)
def handleMsg(self, connection, cmd, msg): CC_Server.handleMsg(self, connection, cmd, msg) if(cmd == 40): # on new join we send everyone's images to the new conn self.connections.sendUserData(connection) elif(cmd == 201): # font update cmd self.connections.updateUserFont(connection, msg) elif(cmd == 202): # avatar update cmd self.connections.updateUserAvatar(connection, msg)
def __init__(self): CC_Server.__init__(self) self.HTTPServ.mimeTypes["ttf"] = "application/octet-stream" self.HTTPServ.mimeTypes["woff"] = "application/octet-stream" self.HTTPServ.mimeTypes["woff2"] = "application/octet-stream" self.HTTPServ.mimeTypes["svg"] = "application/octet-stream" self.HTTPServ.mimeTypes["eot"] = "application/octet-stream" self.HTTPServ.mimeTypes["otf"] = "application/octet-stream" self.HTTPServ.redirects["/"] = "CursiveClient.html"
def __init__(self): CC_Server.__init__(self) skypePrefs = { "room_id": '#mattwitkowski/$cbd88fa129f3d1f0', \ } self.prefs.update(skypePrefs) self.skype = Skype4Py.Skype(Events=self) for chat in self.skype.Chats: if(chat.Name == self.prefs["room_id"]): self.chat = chat log(self, "listening to %s" % self.prefs["room_id"])
def __init__(self): CC_Server.__init__(self) self.tileGrid = list() self.imageList = list() self.HTTPServ.redirects['/'] = "TIAClient.html" self.HTTPServ.isAuthorized = self.connections.checkAuthKey self.HTTPServ.fileUploaded = self.addNewTile tiaPrefs = { \ "grid_filename": "tileGrid.dat", \ "tile_filename": "tileImages.dat", \ "pos_filename": "/dev/null", \ } self.prefs.update(tiaPrefs)
def __init__(self): CC_Server.__init__(self) relayPrefs = { \ "relay_port": 1813, \ "relay_addr": "cho.cyan.com", \ "shadow_users": 0, \ } self.prefs.update(relayPrefs) self.shadowUserList = list() self.shadowListLock = threading.Lock() # bouncer feature - always on in case of config change bouncerPingThread = threading.Thread(None, self.bouncerPingLoop, "bouncerPingLoop", ()) bouncerPingThread.setDaemon(1) bouncerPingThread.start()
def handleMsg(self, connection, cmd, msg): if(connection.status == 2 and cmd != 40): self.connections.sendPM(CC_Server.chatServer(3), connection, "Access denied.", 1) elif(cmd == 40): # announce connection.version = int(msg) if(connection.status == 2): banMsg = ["This ip address[/%s] is blocked from using CyanChat until tomorrow." % connection.addr[0]] self.connections.sendWelcome(connection, banMsg) return elif(cmd == 10): # set name connection.lastAttemptedName = msg else: if(self.prefs["enable_admin_extensions"]): self.handleExt(connection, cmd, msg) if(self.prefs["enable_bouncer"]): self.handleBounce(connection, cmd, msg) if(cmd in [50, 51, 53]): self.sendShadowUserList() elif(cmd in [10, 40] or (cmd in [15, 20, 30, 70] and connection.named)): if(self.prefs["shadow_users"] and cmd in [20, 70]): # If a PM or ignore message is directed at a client of the relay, we bypass the main server msglist = msg.split("|", 1) user = msglist[0].split(",", 1) target = self.connections.findByName(user[0]) if(target): if(cmd == 20): self.connections.sendPM(connection, target, msglist[1][2:]) elif(cmd == 70): self.connections.sendIgnore(connection, target) self.sendShadowUserList() return log(self, "forwarding %s to server" % "%d|%s" % (cmd, msg), 2) connection.forward("%d|%s" % (cmd, msg)) if(cmd == 15): # logout (must be done after forward, or the above will block it) connection.named = 0
def handleMsg(self, connection, cmd, msg): CC_Server.handleMsg(self, connection, cmd, msg) if(cmd == 30): msg = msg[2:] if(connection.level() > 0): # save the results if it's a grid changing message if(msg.startswith("setGrid")): self.tileGrid = msg.split('|') self.updateGridFile() elif(msg.startswith("setTile")): args = msg.split('|') index = int(args[1]) + int(args[2]) * int(self.tileGrid[2]) + int(args[3]) * int(self.tileGrid[2]) * int(self.tileGrid[3]) self.tileGrid[index + 11] = args[4] self.updateGridFile() if(msg.startswith("playerMove")): # name, <pos>, light args = msg.split('|') player = self.connections.findByName(args[1]) # permissions: you can only edit your own pos unless you're admin or guested if(player and (player == connection or connection.level() > 0)): self.connections.updatePlayer(player, '|'.join(args[2:5]), args[5]) else: self.connections.sendPlayerPosList()
def insert(self, connection): CC_Server.connectionList.insert(self, connection) connection.relaySock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: connection.relaySock.connect((self.parent.prefs["relay_addr"], self.parent.prefs["relay_port"])) connection.connectEvent.set() relayRecvThread = threading.Thread(None, self.parent.relayRecvLoop, "relayRecvLoop", (connection,)) relayRecvThread.setDaemon(1) relayRecvThread.start() except: #except Exception as error: #print error log(self, "error connecting to relay target %s" % self.parent.prefs["relay_addr"], 2) self.sendPM(CC_Server.chatServer(3), connection, "Error connecting to relay target", 1) connection.connectEvent.set() #allow the loop to run, but it will throw errors on every forward
def start(self): self.readTileData() CC_Server.start(self)
def readPrefs(self, filename="CCServer.conf"): # force the censor off, it interferes with sending images CC_Server.readPrefs(self, filename) self.prefs["censor_level"] = 0