def sendRawCommand(self, rawCommand): # create MSG object from rawCommand message = MSG(rawCommand) # trying to get message (to be sure rawCommand is a MSG action) try: messageString = message.getMessage() except CommandException: return # trying to find substring with word 'bor' if messageString.find("bor") == 0: # construct outgoing message to send it to chat self.sendMessageToChat(u"Кто-то жаждит бор!") return
def sendMessageToChat(self, message): outgoingMessage = MSG() outgoingMessage.setMessage(message) outgoingMessage.setMessageType(MessageType.B) outgoingMessage.setSourceSID(self.getSid()) # send outgoing message Broadcast.getInstance().broadcast(outgoingMessage.getRawCommand(), self) return