public async void WriteUser(string command, Moderator user)
        {
            var client = new SlackAPI.SlackTaskClient(Config.SlackToken);

            if (!client.ConnectAsync().Result.ok)
            {
                return;
            }

            string userId = "";

            foreach (var x in client.UserLookup)
            {
                if (String.Equals(x.Value.name, user.Name, StringComparison.InvariantCultureIgnoreCase))
                {
                    userId = x.Value.id;
                    break;
                }
            }

            var channel = await client.JoinDirectMessageChannelAsync(userId);

            var result = await client.PostMessageAsync(channel.channel.id, command, "Consensusbot");

            if (result.ok)
            {
                return;
            }
            else
            {
                Console.Write("something went wrong");
            }
        }
      public async void WriteUser(string command, Moderator user)
      {
         var client = new SlackAPI.SlackTaskClient(Config.SlackToken);
         if (!client.ConnectAsync().Result.ok)
         {
            return;
         }

         string userId = "";

         foreach (var x in client.UserLookup)
         {
            if (String.Equals(x.Value.name, user.Name, StringComparison.InvariantCultureIgnoreCase))
            {
               userId = x.Value.id;
               break;
            }
         }

         var channel = await client.JoinDirectMessageChannelAsync(userId);

         var result = await client.PostMessageAsync(channel.channel.id, command, "Consensusbot");
         if (result.ok)
         {
            return;
         }
         else
         {
            Console.Write("something went wrong");
         }
      }
        private async Task <SlackAPI.UserListResponse> GetSlackUserData()
        {
            var client = new SlackAPI.SlackTaskClient(Config.SlackToken);

            return(await client.GetUserListAsync());
        }
      private async Task<SlackAPI.UserListResponse> GetSlackUserData()
      {
         var client = new SlackAPI.SlackTaskClient(Config.SlackToken);

         return await client.GetUserListAsync();
      }
Exemple #5
0
 public SlackService(IConfiguration configuration, IMapper mapper)
 {
     _configuration = configuration;
     _slackClient   = new SlackAPI.SlackTaskClient(GetSlackToken());
     _mapper        = mapper;
 }