Esempio n. 1
0
def send_to_channel(user, channel, msg, do_emote=False):
    args = msg.split()

    if channel.type is 0:
        user_list = [user]
    elif channel.type is 1:
        user_list = mud.users
    elif channel.type is 2:
        user_list = user.room.occupants
    elif channel.type is 3:
        user_list = user.table.users if user.table else []
    elif channel.type is 4:
        user_list = [mud.get_user(args[0])]
        args = args[1:]
        msg = ' '.join(args)
        if msg[0] is '@':
            do_emote = True
            msg = msg[1:]
            args = msg.split()
    else:
        user_list = []

    if do_emote:
        if len(args) > 1:
            if args[1] == "self":
                vict = user
            else:
                vict = None
                for u in user_list:
                    if u.name == args[1]:
                        vict = u
            if vict is None:
                user.presenter.show_msg("{} appears not to be here...".format(args[1]))
                return
        else:
            vict = None
        emote = get_emote(args[0], user, vict)
        if emote is None:
            user.presenter.show_msg("Emote not found.")
            return

        if vict is not None and vict is not user:
            others = [u for u in user_list if u is not user and u is not vict and channel.key in u.db.listening]
            msg_vict = emote['vict']
        else:
            others = [u for u in user_list if u is not user and channel.key in u.db.listening] if emote['others'] is not None else None
        msg_user = emote['user']
        msg_others = emote['others']
    else:
        others = [u for u in user_list if u is not user and channel.key in u.db.listening]
        msg_user = '******' + msg
        msg_others = user.name + ': ' + msg

    user.presenter.show_channel(channel, msg_user)
    if do_emote and vict is not None and vict is not user:
       vict.presenter.show_channel(channel, msg_vict)
    if others is not None:
        for other in others:
            other.presenter.show_channel(channel, msg_others)
Esempio n. 2
0
    def load(self, dbUser):
        other = mud.get_user(dbUser.name)
        if other:
            other.presenter.show_msg("You have signed in from another location!")
            other.disconnect()

        self.authd = True
        self.name = str(dbUser.name)
        self.flags = dict(dbUser.flags)
        self.deck = dbUser.deck
        self.decks = dbUser.decks
        self.db = dbUser
        mud.add_user(self)
        self.room = mud.get_room(config.LOBBY_ROOM_NAME)
        self.room.occupants.append(self)
Esempio n. 3
0
def do_freeze(user, args):
    """
    Set frozen flag for a user
    """
    if not user.is_admin():
        user.presenter.show_msg("Huh?")
        return
    if args is None:
        user.presenter.show_msg("Freeze who?")
        return
    username = args[0]
    victim = mud.get_user(username)
    if victim is None:
        user.presenter.show_msg("Could not find user '{}'.".format(username))
        return
    victim.flags['frozen'] = True
    victim.save()
    victim.presenter.show_msg("&RYou have been frozen solid!&x")
    user.presenter.show_msg("&CYou have frozen {}.&x".format(victim.name))
Esempio n. 4
0
def do_ban(user, args):
    """
    Set banned flag for a user
    """
    if not user.is_admin():
        user.presenter.show_msg("Huh?")
        return
    if args is None:
        user.presenter.show_msg("Ban who?")
        return
    username = args[0]
    victim = mud.get_user(username)
    if victim is None:
        user.presenter.show_msg("Could not find user '{}'.".format(username))
        return
    victim.flags['banned'] = True
    victim.save()
    victim.presenter.show_msg("&RYou have been banned!&x")
    user.presenter.show_msg("&CYou have banned {}.&x".format(victim.name))
    do_quit(victim, None)
Esempio n. 5
0
def do_mute(user, args):
    """
    Set mute flag for a user.
    """
    if not user.is_admin():
        user.presenter.show_msg("Huh?")
        return
    if args is None:
        user.presenter.show_msg("Mute who?")
        return
    user_name = args[0]
    victim = mud.get_user(user_name)
    if user is None:
        user.presenter.show_msg("Could not find user '{}'.".format(user_name))
        return
    victim.flags['muted'] = True
    victim.save()
    victim.presenter.show_msg("&RYou have been muted!&x")
    user.presenter.show_msg("&CYou have muted {}.&x".format(victim.name))
    return
Esempio n. 6
0
def do_make_admin(user, args):
    """
    Set the admin flag for a user.
    """
    if user.name != config.ADMIN:
        user.presenter.show_msg("Huh?")
        return
    if args is None:
        user.presenter.show_msg("Make who an Admin?")
        return
    user_name = args[0]
    u = mud.get_user(user_name)
    if u is None:
        user.presenter.show_msg("Could not find user '{}'.".format(user_name))
        return
    if u.is_admin():
        user.presenter.show_msg("They are already an Admin!")
        return
    u.flags['admin'] = True
    u.save()
    u.presenter.show_msg("&RYou have been made an Admin!&x")
    user.presenter.show_msg("&CYou have admin'd {}.&x")