.setavatar, unhide now flexible, avatar is now in data/ folder

This commit is contained in:
Master Kwoth 2016-02-14 02:51:28 +01:00
parent 5fbd4c9f1a
commit 6fb9b37217
5 changed files with 21 additions and 24 deletions

View File

@ -445,19 +445,29 @@ namespace NadekoBot.Modules {
await client.CurrentUser.Edit(NadekoBot.password, e.GetArg("new_name")); await client.CurrentUser.Edit(NadekoBot.password, e.GetArg("new_name"));
}); });
/*
cgb.CreateCommand(".newavatar") cgb.CreateCommand(".newavatar")
.Alias(".setavatar") .Alias(".setavatar")
.Description("Sets the new avatar from the image URL. PNG and JPEG supported") .Description("Sets a new avatar image for the NadekoBot.")
.Parameter("new_avatar", ParameterType.Required) .Parameter("img", ParameterType.Unparsed)
.Do(async e => { .Do(async e => {
if (e.User.Id != NadekoBot.OwnerID || e.GetArg("new_avatar") == null) return; if (e.User.Id != NadekoBot.OwnerID || string.IsNullOrWhiteSpace(e.GetArg("img")))
var arg = e.GetArg("new_avatar").Trim(); return;
ImageType imgType = arg.EndsWith("png") ? ImageType.Png: ImageType.Jpeg; // Gather user provided URL.
var res = await Searches.GetResponseStream(e.GetArg("new_avatar")); string avatarAddress = e.GetArg("img");
await client.CurrentUser.Edit(NadekoBot.password, avatar: res, avatarType: imgType); // Creates an HTTPWebRequest object, which references the URL given by the user.
System.Net.HttpWebRequest webRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(Uri.EscapeUriString(avatarAddress));
// Discard the response if image isnt downloaded in 5 s as to not lock Nadeko. Prevents loading from faulty links.
webRequest.Timeout = 5000;
// Gathers the webRequest response as a Stream object.
System.Net.WebResponse webResponse = await webRequest.GetResponseAsync();
// Create image object from the response we got from the webRequest stream. This is because there is no "GetResponseStream".
System.Drawing.Image image = System.Drawing.Image.FromStream(webResponse.GetResponseStream());
// Save the image to disk.
image.Save("data/avatar.png", System.Drawing.Imaging.ImageFormat.Png);
await client.CurrentUser.Edit(NadekoBot.password, avatar: image.ToStream());
// Send confirm.
await e.Send("New avatar set.");
}); });
*/
cgb.CreateCommand(".setgame") cgb.CreateCommand(".setgame")
.Description("Sets the bots game.") .Description("Sets the bots game.")
.Parameter("set_game", ParameterType.Unparsed) .Parameter("set_game", ParameterType.Unparsed)

View File

@ -334,8 +334,8 @@ namespace NadekoBot.Modules {
cgb.CreateCommand("unhide") cgb.CreateCommand("unhide")
.Description("Unhides nadeko in plain sight!1!!1") .Description("Unhides nadeko in plain sight!1!!1")
.Do(async e => { .Do(async e => {
using (Stream ms = Resources.nadeko.ToStream()) { using (FileStream fs = new FileStream("data/avatar.png", FileMode.Open)) {
await client.CurrentUser.Edit(NadekoBot.password, avatar: ms, avatarType: ImageType.Jpeg); await client.CurrentUser.Edit(NadekoBot.password, avatar: fs);
} }
await e.Send("*unhides*"); await e.Send("*unhides*");
}); });

View File

@ -670,16 +670,6 @@ namespace NadekoBot.Properties {
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap nadeko {
get {
object obj = ResourceManager.GetObject("nadeko", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>

View File

@ -163,9 +163,6 @@
<data name="king_of_spades" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="king_of_spades" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\images\cards\king_of_spades.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\resources\images\cards\king_of_spades.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="nadeko" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\images\nadeko.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="queen_of_clubs" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="queen_of_clubs" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\images\cards\queen_of_clubs.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\resources\images\cards\queen_of_clubs.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>

View File

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB