Example #1
0
        public async Task <IDictionary <string, User> > GetUserListAsync()
        {
            var response = await _client.GetUserListAsync();

            if (response.ok)
            {
                return(response.members.ToDictionary(a => a.id, a => a));
            }

            _logger.LogError("{Error} getting users from slack ", response.error);
            return(_emptyUsers);
        }
Example #2
0
        static async Task Main(string[] args)
        {
            string TOKEN = Environment.GetEnvironmentVariable("SLACK_TOKEN");

            if (String.IsNullOrEmpty(TOKEN))
            {
                throw new Exception("Please provide a SLACK_TOKEN environment variable");
            }
            var dop      = Environment.GetEnvironmentVariable("SLACK_MAXDOP");
            var dopValue = 1;

            if (dop != null && Int32.TryParse(dop, out dopValue))
            {
                MAX_DEGREE_OF_PARALLELISM = dopValue;
            }
            Console.WriteLine("Parallel processing threads: " + MAX_DEGREE_OF_PARALLELISM);
            var slackClient = new SlackTaskClient(TOKEN);

            var list = await slackClient.GetChannelListAsync();

            Console.WriteLine("channels: " + list.channels.Count());
            var users = await slackClient.GetUserListAsync();

            Console.WriteLine("users: " + users.members.Count());

            var tasks = new List <Task>();

            foreach (var channel in list.channels)
            {
                tasks.Add(CheckStuff(slackClient, channel, users));
            }
            await Task.WhenAll(tasks.ToArray());

            Console.WriteLine("");
            Console.WriteLine("------------------------------------------------------------");
            Console.WriteLine("");
            var counts = peoples.GroupBy(s => s).OrderByDescending(x => x.Count());

            foreach (var cnt in counts)
            {
                Console.WriteLine(cnt.Key + ": " + cnt.Count());
            }
        }