Пример #1
0
        public async Task Load(string channelMention)
        {
            var    eb        = new BotEmbedBuilder();
            string channelId = Regex.Match(channelMention, @"\d+").Value;

            SocketTextChannel textChannel = null;

            if (!string.IsNullOrEmpty(channelId))
            {
                textChannel = Context.Guild.GetTextChannel(ulong.Parse(channelId));
            }

            var typingState = Context.Channel.EnterTypingState();

            if (textChannel != null)
            {
                try
                {
                    _messages = _messages.Union(await textChannel.GetMessagesAsync(Int32.MaxValue).FlattenAsync());
                    eb.WithDescription("Messages fetched.");
                }
                catch (HttpException)
                {
                    eb.WithDescription("I can't access that text channel. Do I have permission to read messages there?");
                }
            }
            else
            {
                eb.WithDescription("I can't find that text channel. Try mentioning a valid text channel like this:" +
                                   "```#{Context.Channel.Name}```");
            }

            typingState.Dispose();
            await ReplyAsync("", false, eb.Build());
        }
Пример #2
0
        public async Task Train()
        {
            var typingState = Context.Channel.EnterTypingState();

            ClassificationService.LoadMessages(_messages);

            typingState.Dispose();
            var eb = new BotEmbedBuilder();

            eb.WithDescription("Training complete.");
            await ReplyAsync("", false, eb.Build());
        }
Пример #3
0
        public async Task Predict([Remainder] String content)
        {
            SimpleTextMessage simpleMessage = new SimpleTextMessage
            {
                Content = content
            };
            var userId   = ClassificationService.PredictUser(simpleMessage);
            var username = Context.Guild.GetUser(userId).Username;
            var eb       = new BotEmbedBuilder();

            eb.WithDescription($"\"{content}\" - {username} (probably)");
            await ReplyAsync("", false, eb.Build());
        }