public async void RandomTest() { var result = await _giphy.RandomGif(new RandomParameter() { Tag = "american psycho" }); }
async void GetGif(string url) { var giphy = new Giphy("dc6zaTOxFJmzC"); var gifresult = await giphy.RandomGif(new RandomParameter() { Tag = searchingText }); try { using (var client = new HttpClient()) { if (url == null) // refresh gif { this.url = "https://media.giphy.com/media/" + gifresult.Data.Id.ToString() + "/giphy.gif"; //Toast.MakeText(this, "1", ToastLength.Short).Show(); } else // load from json { this.url = url; //Toast.MakeText(this, "2", ToastLength.Short).Show(); } var bytes = await client.GetByteArrayAsync(this.url); gifImage.SetBytes(bytes); gifImage.StartAnimation(); } } catch (Exception e) { Toast.MakeText(this, "Bad connection", ToastLength.Short).Show(); } }
public async Task GifAsync() { GiphyDotNet.Model.Results.GiphyRandomResult gif = await _giphy.RandomGif(new RandomParameter()); EmbedBuilder embed = new EmbedBuilder() .WithImageUrl(gif.Data.ImageUrl); await ReplyEmbedAsync(embed); }
public async void RandomGifSearch() { var gifResult = await giphy.RandomGif(new RandomParameter() { Tag = "american psycho" }); Assert.True(gifResult != null); }
public async Task RandomGif([Remainder, Summary("Search term")] string term) { var result = await _giphyService.RandomGif(new GiphyDotNet.Model.Parameters.RandomParameter() { Tag = term }); await Context.Channel.SendMessageAsync(result.Data.Url); }
public async Task GifAsync() { var gif = await _giphy.RandomGif(new RandomParameter()); var embed = new EmbedBuilder() .WithImageUrl(gif.Data.ImageUrl); await ReplyEmbedAsync(embed); }
public async Task <string> GetRandomGif(string searchParameter) { var giphy = new Giphy(Configuration["RemotePuzzle:GiphyApiKey"]); var randomGif = await giphy.RandomGif(new GiphyDotNet.Model.Parameters.RandomParameter { Tag = searchParameter }); return(randomGif.Data.ImageMp4Url); }
public async Task Ban([Remainder] SocketGuildUser user) { var gif = await giphyService.RandomGif(new RandomParameter() { Tag = "banhammer" }); var message = $"{user.Mention} :wave: \n{gif.Data.Url}"; await Context.Channel.SendMessageAsync(message); }
protected void OnMessage(string user, string message, DateTime timestamp) { if (message.StartsWith("@giphy ", StringComparison.InvariantCultureIgnoreCase)) { var search = new RandomParameter() { Tag = message.Substring(7) }; m_giphy.RandomGif(search).ContinueWith(task => Send("@" + user + ": " + task.Result.Data.ImageUrl)); } }
public async Task <string> Execute() { var gifRequest = new RandomParameter { Tag = _isAvailable ? _settings.GiphyTextYes : _settings.GiphyTextNo, }; var gif = await _giphyClient.RandomGif(gifRequest); return(gif.Data.ImageUrl); }
public static async Task <String> Run( [ServiceBusTrigger("birthdayalert", Connection = "PeopleServiceBusConnection")] string myQueueItem, ILogger log) { if (myQueueItem is "null") { return(null); } // log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}"); string api_key = Environment.GetEnvironmentVariable("GiphyAPIKey"); try { var giphy = new Giphy(api_key); var parameters = new RandomParameter() { Tag = "happybirthday", Rating = Rating.G }; var gifResult = await giphy.RandomGif(parameters); Person person = JsonSerializer.Deserialize <Person>(myQueueItem); person.gif = gifResult; // return person; string personJsonString = JsonSerializer.Serialize(person); return(personJsonString); } catch (HttpRequestException e) { Console.WriteLine("\nException Caught!"); Console.WriteLine("Message :{0} ", e.Message); return(null); } }
public async Task Gif() { // Get the giphy token from the config file. string giphyToken = this.config["tokens:giphy"]; if (string.IsNullOrWhiteSpace(giphyToken)) { await ReplyAsync("No Giphy app token provided. Please enter token into the `config.json` file found in the applications root directory."); } else { Giphy giphy = new Giphy(giphyToken); RandomParameter randomGif = new RandomParameter(); // Returns gif results. var gifResult = await giphy.RandomGif(randomGif); var imageUrl = new EmbedBuilder() .WithImageUrl(gifResult.Data.ImageOriginalUrl).Build(); await ReplyAsync("", embed: imageUrl); } }
public static void Run([TimerTrigger("0 0 16 * * *")] TimerInfo myTimer, ILogger log, ExecutionContext context) { var config = new ConfigurationBuilder() .SetBasePath(context.FunctionAppDirectory) .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true) .AddEnvironmentVariables() .Build(); string term = "disappointment"; string dayStatement = "Checking to see if it is Friday..."; // check to see if it is a friday var today = DateTime.Now.ToUniversalTime().AddHours(-7); switch (today.DayOfWeek) { case DayOfWeek.Sunday: case DayOfWeek.Saturday: return; case DayOfWeek.Monday: term = "ugh monday"; dayStatement = "Ugh, Monday."; break; case DayOfWeek.Tuesday: break; case DayOfWeek.Wednesday: break; case DayOfWeek.Thursday: break; case DayOfWeek.Friday: term = "friyay"; break; default: term = "disappointment"; break; } if (config["debug"] == "true") { term = config["debug_term"]; } var g = new Giphy(config["GiphyKey"]); var gifresult = g.RandomGif(new RandomParameter() { Tag = term, Rating = Rating.Pg }); var url = gifresult.Result.Data.ImageUrl; WebClient wc = new WebClient(); byte[] imageData = wc.DownloadData(url); var tokens = Tokens.Create(config["APIKey"], config["APISecret"], config["AccessToken"], config["AccessSecret"]); var uploadedMedia = tokens.Media.Upload(imageData); var ids = new long[] { uploadedMedia.MediaId }; try { tokens.Statuses.UpdateAsync($"{dayStatement}\n\n\n(powered by GIPHY)", null, null, null, null, null, null, null, ids, null, null, null, null, null, null, null); } catch (Exception e) { log.LogError(e.Message); } }