Example #1
0
 public GiphyModule(ChannelServices channelServices, GiphyApi api, ServerServices serverServices, Server server)
 {
     _channelServices = channelServices;
     _api             = api;
     _serverServices  = serverServices;
     _prefix          = _serverServices.GetGuildPrefix(server.Id).Result;
 }
Example #2
0
 public VkController(ulong groupid, string apptoken, string gtoken)
 {
     this.groupid = groupid;
     this.gapi    = new GiphyApi(gtoken);
     api.Authorize(new ApiAuthParams()
     {
         AccessToken = apptoken
     });
     longPollClient.Message += MessageReceived;
     longPollClient.Error   += ErrorReceived;
 }
Example #3
0
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            var activity  = await result as Activity;
            var botHandle = ConfigurationManager.AppSettings["BotId"];
            var giphyApi  = new GiphyApi(ConfigurationManager.AppSettings["GiphyApiToken"]);

            var requesterName = activity.From.Name;
            var queryText     = activity.RemoveMentionText(botHandle);

            queryText = queryText.Replace($"@{botHandle} ", "");

            var imageUrl = await giphyApi.GetImageUrlFromText(queryText);

            var responseText = $"{requesterName} searched for '{queryText}' \n\n {imageUrl}";
            await context.PostAsync(responseText);

            context.Wait(MessageReceivedAsync);
        }