示例#1
0
        /// <summary>
        /// Maps AuthNames of the IRC-network to ingame Account names.
        /// Should be saved to/loaded from a file.
        /// Should be maintainable of People with high enough priv levels (check Role.IsAdmin)
        /// </summary>
        /// <summary>
        /// Adds an AuthResolved handler
        /// </summary>
        /// <param name="irc"></param>
        public static void Init(IrcClient irc)
        {
            irc.AuthMgr.AuthResolved += usr =>
            {
                if (!RealmServer.Instance.AuthClient.IsConnected)
                {
                    usr.Msg("AuthServer is offline, authentication disabled.");
                    return;
                }
                var acc = GetAccount(usr.AuthName);
                if (acc != null)
                {
                    var wcellUser = new WCellUser(acc, usr);
                    var args      = new WCellArgs(acc);
                    usr.Args = args;

                    if (args.Account.Role >= RoleStatus.Staff)
                    {
                        args.CmdArgs = new RealmServerCmdArgs(wcellUser, false, null);
                    }
                }
                else
                {
                    // User cannot use commands because he does not have a verified Account
                    // maybe send him a link to register online
                    usr.Msg("You do not have sufficient rights");
                }
            };
        }
示例#2
0
        public static bool HandleCommand(WCellUser wcellUser, IrcUser user, IrcChannel chan, string text)
        {
            var uArgs = user.Args as WCellArgs;

            if (uArgs != null)
            {
                if (uArgs.Account.Role >= RoleStatus.Staff)
                {
                    var cmdArgs = uArgs.CmdArgs;
                    var trigger = new WCellCmdTrigger(wcellUser, chan, new WCellStr(text), cmdArgs);

                    bool isDouble;
                    RealmCommandHandler.ConsumeCommandPrefix(trigger.Text, out isDouble);
                    trigger.Args.Double = isDouble;

                    // init the trigger and check if the given args are valid
                    if (trigger.InitTrigger())
                    {
                        RealmCommandHandler.Instance.ExecuteInContext(trigger, OnExecuted, OnFail);
                    }
                    return(true);
                }
            }
            return(false);
        }
示例#3
0
 public WCellCmdTrigger(WCellUser user, IrcChannel channel, WCellStr text, RealmServerCmdArgs args)
     : base(text, args)
 {
     Channel = channel;
     User    = user.IrcUser;
 }