Esempio n. 1
0
        //
        #endregion

        internal CommandBase(CommandBaseBuilder commandBase, MethodInfo method, Type module)
        {
            Module      = module;
            Name        = commandBase.Name;
            Aliases     = commandBase.InAliases;
            Description = commandBase.InHelpDescription;
            Button      = commandBase.InButton;
            CommandType = commandBase.CommandType;

            //* This is for new features, to help separate them from the original implementation. *//
            #region Extensibility Constructor
            Permissions = commandBase.Permissions;
            StepInfo    = commandBase.StepInfo;
            #endregion

            if (CommandType != CommandType.Default)
            {
                // Primary invoker is not used.
                Invoke = (ctx) => Task.CompletedTask;
            }
            else
            {
                if (AuxiliaryMethods.TryConvertDelegate <TContext, TArgs>(method, out var c))
                {
                    Invoke = c;
                }
                else
                {
                    throw new ArgumentException();
                }
            }
        }
Esempio n. 2
0
        public void TestMakeGreetingsFunctionId2()
        {
            string expected = $"Приветствую, Влад :)";
            string actual   = AuxiliaryMethods.MakeGreetings(userName: "******");

            Assert.AreEqual(expected, actual);
        }
Esempio n. 3
0
        public void TestMakeGreetingsFunctionId1()
        {
            string expected = $"Приветствую, Ксюша :)";
            string actual   = AuxiliaryMethods.MakeGreetings(userName: "******");

            Assert.AreEqual(expected, actual);
        }
Esempio n. 4
0
        public void TestMakeInfoFunction()
        {
            string expected = "Команда для меня начинается с \"curry \" . \n После обращения можно вводить следующие запросы: \n" +
                              "\"привет\" \n \"какой день недели\" \n \"какая погода в городе N\" \n " +
                              "\"покажи новости\" \n \"нужна помощь\" \n" +
                              "\"расскажи гороскоп N\" \n \"покажи цитату\" \n" +
                              "\" расскажи анекдот \" \n \" расскажи историю \" \n";
            string actual = AuxiliaryMethods.MakeInfo();

            Assert.AreEqual(expected, actual);
        }
Esempio n. 5
0
 /// <summary>
 /// Labels a method to be constructed into a proper <see cref="Command"/> object.
 /// <para><see cref="Command"/> names may only be a maximum of 255 characters, and cannot contain any whitespace characters.</para>
 /// </summary>
 /// <param name="name"></param>
 public CommandAttribute(string name)
 {
     AuxiliaryMethods.CheckCommandNameValidity(name);
     Name = name;
 }