Esempio n. 1
0
 private Response(ResponseType type, string message, ILazySocketMessageChannel channel, ILazySocketUser replyTo = null)
 {
     Type    = type;
     Message = message;
     Channel = channel;
     ReplyTo = replyTo;
 }
Esempio n. 2
0
 public async Task StartAsync(ILazySocketMessageChannel channel, ILazySocketUser user, bool force, Expr.Main expr, int maxSize, bool noProgress)
 {
     if (channel == null)
     {
         throw new ArgumentNullException(nameof(channel));
     }
     if (user == null)
     {
         throw new ArgumentNullException(nameof(user));
     }
     await StartAsync(await channel.GetIdAsync(), await user.GetIdAsync(), await user.GetUsernameAsync(), force, expr, maxSize, noProgress);
 }
Esempio n. 3
0
        /// <summary>他の BOT による、Mention を含まないメッセージを作成します。</summary>
        public static TestLazySocketMessage CreateOtherBotMessage(string context, ILazySocketUser author = null)
        {
            var _author = author ?? TestLazySocketUser.AnotherBot;
            var mentionedUsers = new TestLazySocketUser[] { }.ToReadOnly();

            return(new TestLazySocketMessage
            {
                Author = _author,
                Channel = TestLazySocketMessageChannel.Default,
                Content = $"{context}",
                MentionedUsers = mentionedUsers
            });
        }
Esempio n. 4
0
        /// <summary>ダイス BOT への Mention を含むメッセージを作成します。</summary>
        public static TestLazySocketMessage CreateMentionedMessage(string context, ILazySocketUser author = null)
        {
            var _author = author ?? TestLazySocketUser.Author;
            var mentionedUsers = new[] { TestLazySocketUser.MyBot }.ToReadOnly();

            return(new TestLazySocketMessage
            {
                Author = _author,
                Channel = TestLazySocketMessageChannel.Default,
                Content = $"<@{TestLazySocketUser.MyBot.Id}> {context}",
                MentionedUsers = mentionedUsers
            });
        }
Esempio n. 5
0
        public async Task GetLatestProgressAsync(ILazySocketMessageChannel channel, ILazySocketUser user, bool shuffled)
        {
            if (channel == null)
            {
                throw new ArgumentNullException(nameof(channel));
            }
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            await GetLatestProgressAsync(await channel.GetIdAsync(), await user.GetIdAsync(), shuffled);
        }
Esempio n. 6
0
 protected abstract Task <Response> InvokeCoreAsync(ILazySocketClient client, ILazySocketMessageChannel channel, ILazySocketUser user);
Esempio n. 7
0
        protected override async Task <Response> InvokeCoreAsync(ILazySocketClient client, ILazySocketMessageChannel channel, ILazySocketUser user)
        {
            var noResult = _noResultOption.HasOption;

            if (noResult)
            {
                await _scanMachine.AbortAsync(await channel.GetIdAsync(), await user.GetIdAsync());
            }
            else
            {
                await _scanMachine.EndAsync(await channel.GetIdAsync(), await user.GetIdAsync());
            }
            return(Response.None);
        }
Esempio n. 8
0
        protected override async Task <Response> InvokeCoreAsync(ILazySocketClient client, ILazySocketMessageChannel channel, ILazySocketUser user)
        {
            await _scanMachine.GetLatestProgressAsync(channel, user, _shuffledOption.HasOption);

            return(Response.None);
        }
Esempio n. 9
0
        protected override async Task <Response> InvokeCoreAsync(ILazySocketClient client, ILazySocketMessageChannel channel, ILazySocketUser user)
        {
            var dice       = _diceOption.Value ?? Expr.Main.Interpret("1d100").Value;
            var maxSize    = _maxSizeOption.Value ?? int.MaxValue;
            var noProgress = _noProgressOption.HasOption;
            var force      = _forceOption.HasOption;
            await _scanMachine.StartAsync(channel, user, force, dice, maxSize, noProgress);

            return(Response.None);
        }
Esempio n. 10
0
 protected override async Task <Response> InvokeCoreAsync(ILazySocketClient client, ILazySocketMessageChannel channel, ILazySocketUser user)
 => await CommandActions.Changelog(client, channel);
Esempio n. 11
0
 public static Response TryCreateSay(string message, ILazySocketMessageChannel channel, ILazySocketUser replyTo = null)
 {
     return(TryCreate(ResponseType.Say, message, channel, replyTo));
 }
Esempio n. 12
0
 private static Response TryCreate(ResponseType type, string message, ILazySocketMessageChannel channel, ILazySocketUser replyTo = null)
 {
     if (message.Length >= 1500) // Discordの文字上限は2000文字(2019/05/02現在)
     {
         return(new Response(ResponseType.Caution, "文字列が長すぎるため、結果を返せませんでした。", channel, replyTo));
     }
     return(new Response(type, message, channel, replyTo));
 }