Just append card url instead of downloading.

This commit is contained in:
fkndean 2016-11-27 20:17:46 -05:00
parent d363af4dfe
commit 7ad43e8345

View File

@ -194,20 +194,6 @@ $@"🌍 **Weather for** 【{obj["target"]}】
await msg.Channel.SendMessageAsync(await NadekoBot.Google.ShortenUrl(arg).ConfigureAwait(false)); await msg.Channel.SendMessageAsync(await NadekoBot.Google.ShortenUrl(arg).ConfigureAwait(false));
} }
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
public async Task Google(IUserMessage umsg, [Remainder] string terms = null)
{
var channel = (ITextChannel)umsg.Channel;
terms = terms?.Trim();
if (string.IsNullOrWhiteSpace(terms))
return;
await channel.SendMessageAsync($"https://google.com/search?q={ WebUtility.UrlEncode(terms).Replace(' ', '+') }")
.ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task MagicTheGathering(IUserMessage umsg, [Remainder] string name = null) public async Task MagicTheGathering(IUserMessage umsg, [Remainder] string name = null)
@ -230,21 +216,16 @@ $@"🌍 **Weather for** 【{obj["target"]}】
try try
{ {
var items = JArray.Parse(response).Shuffle().ToList(); var items = JArray.Parse(response).Shuffle().ToList();
var images = new List<Image>();
if (items == null) if (items == null)
throw new KeyNotFoundException("Cannot find a card by that name"); throw new KeyNotFoundException("Cannot find a card by that name");
var msg = $@"```css
using (var sr = await http.GetStreamAsync(items[0]["editions"][0]["image_url"].ToString())) [☕ Magic The Gathering]: {items[0]["name"].ToString()}
{ [Store URL]: {await _google.ShortenUrl(items[0]["store_url"].ToString())}
var imgStream = new MemoryStream(); [Cost]: {items[0]["cost"].ToString()}
await sr.CopyToAsync(imgStream); [Description]: {items[0]["text"].ToString()}
imgStream.Position = 0; ```
images.Add(new Image(imgStream)); {items[0]["editions"][0]["image_url"].ToString()}";
} await channel.SendMessageAsync(msg).ConfigureAwait(false);
var ms = new MemoryStream();
images.Merge().SaveAsJpeg(ms);
ms.Position = 0;
await channel.SendFileAsync(ms, arg + ".jpg", null).ConfigureAwait(false);
} }
catch catch
{ {