private void MessageBlacklistMethod(ulong id)
        {
            // Tries to store the given ID as a channel, provides feedback if it is not.
            if (Global.IsValidUserId(id))
            {
                Console.WriteLine("Not a valid user ID.");
                return;
            }

            // Writes the ID to a new file if it does not exist, otherwise toggles ID in current list and saves.
            ProgramMessages.ToggleUserBlacklistEntry(id);
        }
        private void InitializeMessages()
        {
            var log1 = ProgramMessages.ChannelMessages();
            var log2 = ProgramMessages.ChannelMessagesCondensed();

            if ((log1 != null && log2 != null) && (log1.Count != 0 && log2.Count != 0))
            {
                Console.WriteLine("Logs loaded successfully.");
            }
            else
            {
                Console.WriteLine("Logs are null.");
            }
        }
Exemple #3
0
 private Task OnMessageReceived(SocketMessage msg)
 {
     if (IsValidUser(msg.Author))
     {
         var user = UserAccounts.GetAccount(msg.Author);
         user.AddCurrency(1);
     }
     if (Global.IsLoggingActive && !LogMessages.DoesValueExistInList(LogMessages.Blacklist(), msg.Channel.Id))
     {
         LogMessages.AddOrAppendChannelLog(msg.Channel.Id, msg.Id);
         ProgramMessages.AddOrAppendChannelLog(msg.Channel, msg);
         LogMessages.AppendLogToStorage(msg.Channel.Id, msg.Id);
     }
     return(Task.CompletedTask);
 }
        public async Task Remember(string phrase = "", string user = "")
        {
            string message = string.Empty;
            // Don't allow command to initiate in DMs
            var guilds = Context.Guild;

            if (guilds == null)
            {
                message = "hey dumbass this command only works in a server";
            }
            else if (ProgramMessages.ChannelMessagesCondensed() == null)
            {
                message = "umm the chat logs haven't been loaded... :(";
            }
            else
            {
                IMessage        msg            = null;
                List <IMessage> serverMessages = new List <IMessage>();
                Dictionary <SocketTextChannel, int> channelMessageCount = new Dictionary <SocketTextChannel, int>();
                foreach (SocketTextChannel channel in guilds.TextChannels)
                {
                    List <IMessage> channelMessages = ProgramMessages.GetSavedChannelMessagesCondensed(channel);
                    if (channelMessages != null)
                    {
                        serverMessages.AddRange(channelMessages);
                        channelMessageCount.Add(channel, channelMessages.Count);
                    }
                }
                if (serverMessages == null)
                {
                    await ReplyAsync("hey dumbass this command only works in a server");

                    return;
                }
                string contents = string.Empty, attachments = string.Empty;
                if (msg.Attachments != null)
                {
                    foreach (var attachment in msg.Attachments)
                    {
                        attachments += attachment.Url + "\n";
                    }
                }
                if (msg.Content != null)
                {
                    contents = msg.Content;
                }

                message = $"remember when {msg.Author.Username.ToLower()} said:\n\"{attachments}\n{contents}\"";
                if (message.Length < Constants.CharacterLimit && attachments == string.Empty)
                {
                    message = $"remember when {msg.Author.Username.ToLower()} said:\n\"{contents}\"";
                }
                else if (message.Length < Constants.CharacterLimit)
                {
                }
                else if (contents == string.Empty)
                {
                    message = $"remember when {msg.Author.Username.ToLower()} uploaded:\n\"{attachments}\"";
                }
                else if (message.Length > Constants.CharacterLimit && message.Length - attachments.Length <= Constants.CharacterLimit)
                {
                    message = $"remember when {msg.Author.Username.ToLower()} said:\n\"{contents}\"";
                }
                else
                {
                    message = contents;
                }
            }
            await ReplyAsync(message);
        }