Esempio n. 1
0
        private async Task DeleteMessages(string channelId, List <Message> messageHistories)
        {
            if (messageHistories == null)
            {
                return;
            }
            int deleteInterval = 300;

            foreach (Message item in messageHistories)
            {
                if (string.IsNullOrEmpty(item.user) || item.user.Equals(UserIdOfToken))
                {
                    DeletedResponse response;
                    do
                    {
                        try
                        {
                            response = await SlackClient.DeleteMessageAsync(channelId, item.ts);
                        }
                        catch (NullReferenceException)
                        {
                            response = new DeletedResponse()
                            {
                                ok = true
                            };
                        }
                        Thread.Sleep(deleteInterval);
                    } while ((response != null && !response.ok) && response.error.Equals(Config.SlackRateLimitError));

                    MessageDeleted?.Invoke();
                }
            }
        }