public async Task Imgur(CommandContext ctx, [Description("Search query to pass to Imgur.")][RemainingText] string query) { await ctx.TriggerTypingAsync(); var results = ImgurService.GetImgurGalleryAsync(Program.Settings.Tokens.ImgurToken, query).Result; var output = new DiscordEmbedBuilder().WithColor(new DiscordColor("#89C623")); switch (results) { case GalleryImage image: output.WithDescription(image.Title ?? "Search results for " + Formatter.Bold(query) + " on Imgur"); output.WithImageUrl(image.Link); await ctx.RespondAsync(output.Build()).ConfigureAwait(false); break; case GalleryAlbum album: output.WithDescription(album.Title ?? "Search results for " + Formatter.Bold(query) + " on Imgur"); output.WithImageUrl(album.Link); await ctx.RespondAsync(output.Build()).ConfigureAwait(false); break; default: await BotServices.SendResponseAsync(ctx, Resources.NOT_FOUND_COMMON, ResponseType.Missing) .ConfigureAwait(false); break; } }
public void UploadTest() { string imageFileName = Path.GetFullPath("snagitimgur.png"); var service = new ImgurService(); UploadResult uploadResult = service.UploadImage(imageFileName); Assert.IsNotNull(uploadResult); }
public async Task GetImgurGalleryData() { var results = await ImgurService.GetImgurGalleryAsync("cats", GallerySortOrder.Top, TimeWindow.All).ConfigureAwait(false); Assert.IsNotNull(results); results = await ImgurService.GetImgurGalleryAsync("dogs", GallerySortOrder.Top, TimeWindow.All).ConfigureAwait(false); Assert.IsNotNull(results); }
public async Task GetImgurGalleryData() { var results = await ImgurService.GetImgurGalleryAsync(TestSetup.Tokens.ImgurToken, "cats") .ConfigureAwait(false); Assert.IsNotNull(results); results = await ImgurService.GetImgurGalleryAsync(TestSetup.Tokens.ImgurToken, "dogs") .ConfigureAwait(false); Assert.IsNotNull(results); }
public async Task InitAsync() { try { string json; using (var sr = new StreamReader("Resources/config.json")) json = await sr.ReadToEndAsync(); var cfg = JsonConvert.DeserializeObject <BotConfig>(json); this.imgur = new ImgurService(cfg.ImgurKey); } catch { Assert.Warn("Config file not found or Imgur key isn't valid (service disabled)."); this.imgur = new ImgurService(null); } }
public void InitializeComponent(object pExtensionHost, IComponent pComponent, componentInitializeType initType) { try { var snagitHost = pExtensionHost as ISnagIt; if (snagitHost == null) { throw new InvalidOperationException("Unable to communicate with Snagit"); } var imgurService = new ImgurService(); var temporaryImageProvider = new TemporaryImageProvider(snagitHost); snagitFacade = new SnagitFacade(snagitHost, temporaryImageProvider, imgurService); } catch (Exception e) { // todo temp code, replace with proper reporting! MessageBox.Show("An unandled exception occured:\n" + e); } }
public async Task Imgur(CommandContext ctx, [Description("Search query to pass to Imgur")][RemainingText] string query) { var results = ImgurService.GetImgurGalleryAsync(query).Result; switch (results) { case GalleryAlbum _: await ctx.RespondAsync(((GalleryAlbum)results).Link).ConfigureAwait(false); break; case GalleryImage _: await ctx.RespondAsync(((GalleryImage)results).Link).ConfigureAwait(false); break; default: await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_GENERIC, EmbedType.Missing).ConfigureAwait(false); break; } }
public AslanModule(ImgurService imgurService, BotConfig config, HttpClient client) { _imgurService = imgurService; _config = config; _client = client; }
public ImgurModule(ImgurService service) { Service = service; }