def __init__(self, bot, game_handler, game_jid, gamelist_jid, bot_nick, autoload, allow_invites, size_limit): MucRoomHandler.__init__(self) self.ia_avatarcache = u''.join([random.choice('0123456789abcdef') for x in range(32)]) self.game_jid = game_jid self.gamelist_jid = gamelist_jid self.bot = bot self.game_handler = game_handler self.commands = IAPartyCommands(self, game=game_handler) self.allow_invites = allow_invites self.size_limit = size_limit self.private = False self.config_form = None # Lobby state self.lobby_started = datetime.utcnow().replace(microsecond=0).isoformat() self.lobby_registered = False # Lobby settings self.bot_nick = bot_nick self.autoload = autoload # Game state self.state = 'lobby' self.loaded = False # Game settings self.level = None self.level_id = None self.mode = 'CTF' self.timelimit = None self.scorelimit = None self.teams = None self.autostart = None
def message_received(self, user, stanza): MucRoomHandler.message_received(self, user, stanza) print str(user.room_jid) if self._jid != user.room_jid and self._listener: msg = util.message.Message(user.nick, user.room_jid.node+u"@"+user.room_jid.domain, stanza.get_body()) print(str(msg)) self._listener(msg)
def message_received(self, user, stanza): MucRoomHandler.message_received(self, user, stanza) # Messages can come from the party and not a user if not user: return if not self.commands.is_admin(user.nick): return msg = stanza.get_body() if not msg: return bang_re = re.compile('^!(\w+)( .*)?$') bang_cmd = bang_re.match(msg) if not bang_cmd: return (command, args) = bang_cmd.groups() command = command.lower() if args: args = args.strip().rstrip() bang_command = self.commands.get_command(command) if bang_command: result = bang_command(user, args) if result: self.room_state.send_message(result)
def message_received(self, user, stanza): MucRoomHandler.message_received(self, user, stanza) print str(user.room_jid) if self._jid != user.room_jid and self._listener: msg = util.message.Message( user.nick, user.room_jid.node + u"@" + user.room_jid.domain, stanza.get_body()) print(str(msg)) self._listener(msg)
def user_left(self, user, stanza): MucRoomHandler.user_left(self, user, stanza) print "*** User left: %s" % user.nick # Why doesn't pyxmpp delete it? if user.nick in self.room_state.users: del self.room_state.users[user.nick] self.shazbot_update_usercount()
def user_joined(self, user, stanza): MucRoomHandler.user_joined(self, user, stanza) print "*** User joined: %s" % user.nick stream = self.room_state.manager.stream if user.nick == self.bot_nick: # Send a basic presence until the game is loaded self.show_presence() self.game_handler.party_handler = self self.game_handler.gamelist_jid = unicode(self.gamelist_jid) # CHANGE: game process will be managed by this, eventually # but our socket will always listen whilst this party is here # if self.autoload: # self.game_thread.start() self.bot.game_listener.listen_for_game() else: pass self.shazbot_update_usercount()
def join_room(self, jid, nick=None, handler=None, **options): if not isinstance(jid, JID): jid = JID(jid) if nick is None: nick = self.jid.node kwargs = { 'history_maxchars': 0, } kwargs.update(options) if jid in self.rooms: return if handler is None: handler = MucRoomHandler() self.rooms[jid] = self.room_manager.join(jid, nick, handler, **kwargs)
def user_left(self, user, stanza): MucRoomHandler.user_left(self, user, stanza)
def nick_changed(self, user, old_nick, stanza): MucRoomHandler.nick_changed(self, user, old_nick, stanza)
def subject_changed(self, user, stanza): MucRoomHandler.subject_changed(self, user, stanza)
def role_changed(self, user, old_role, new_role, stanza): MucRoomHandler.role_changed(self, user, old_role, new_role, stanza)
def __init__(self, jid, listener=None): MucRoomHandler.__init__(self) self._listener = listener self._jid = jid
def user_joined(self, user, stanza): MucRoomHandler.user_joined(self, user, stanza)
def room_created(self, stanza): MucRoomHandler.room_created(self, stanza) print "************** Room Created"
def room_configured(self): print "Room Configured" MucRoomHandler.room_configured(self)
def __init__(self): MucRoomHandler.__init__(self) self.setns = False
def __init__(self, jid): self.jid = jid MucRoomHandler.__init__(self)
def presence_changed(self, user, stanza): MucRoomHandler.presence_changed(self, user, stanza)