RIP & FAQ
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
using Discord;
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using Discord.Modules;
|
||||
using NadekoBot.Classes;
|
||||
@ -198,11 +198,11 @@ namespace NadekoBot.Modules.Conversations
|
||||
var text = "";
|
||||
var avatar = await GetAvatar(usr.AvatarUrl);
|
||||
text = usr?.Name ?? e.GetArg("user");
|
||||
await e.Channel.SendFile("ripzor_m8.png",
|
||||
RipUser(text, avatar, string.IsNullOrWhiteSpace(e.GetArg("year"))
|
||||
var file = RipUser(text, avatar, string.IsNullOrWhiteSpace(e.GetArg("year"))
|
||||
? null
|
||||
: e.GetArg("year")))
|
||||
.ConfigureAwait(false);
|
||||
: e.GetArg("year"));
|
||||
await e.Channel.SendFile("ripzor_m8.png",
|
||||
file);
|
||||
});
|
||||
|
||||
if (!NadekoBot.Config.DontJoinServers)
|
||||
@ -343,34 +343,18 @@ namespace NadekoBot.Modules.Conversations
|
||||
});
|
||||
}
|
||||
|
||||
public Stream RipName(string name, string year = null)
|
||||
{
|
||||
var bm = Resources.rip;
|
||||
|
||||
var offset = name.Length * 5;
|
||||
|
||||
var fontSize = 20;
|
||||
|
||||
if (name.Length > 10)
|
||||
{
|
||||
fontSize -= (name.Length - 10) / 2;
|
||||
}
|
||||
|
||||
//TODO use measure string
|
||||
var g = Graphics.FromImage(bm);
|
||||
g.DrawString(name, new Font("Comic Sans MS", fontSize, FontStyle.Bold), Brushes.Black, 100 - offset, 200);
|
||||
g.DrawString((year ?? "?") + " - " + DateTime.Now.Year, new Font("Consolas", 12, FontStyle.Bold), Brushes.Black, 80, 235);
|
||||
g.Flush();
|
||||
g.Dispose();
|
||||
|
||||
return bm.ToStream(ImageFormat.Png);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a RIP image of the given name and avatar, with an optional year
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="avatar"></param>
|
||||
/// <param name="year"></param>
|
||||
/// <returns></returns>
|
||||
public Stream RipUser(string name, Image avatar, string year = null)
|
||||
{
|
||||
var bm = Resources.rip;
|
||||
var offset = name.Length * 2;
|
||||
|
||||
|
||||
var fontSize = 20;
|
||||
|
||||
if (name.Length > 10)
|
||||
@ -379,16 +363,16 @@ namespace NadekoBot.Modules.Conversations
|
||||
}
|
||||
//var avatar = Image.FromStream(await SearchHelper.GetResponseStreamAsync(aviLink));
|
||||
|
||||
|
||||
|
||||
|
||||
//TODO use measure string
|
||||
var g = Graphics.FromImage(bm);
|
||||
g.DrawString(name, new Font("Comic Sans MS", fontSize, FontStyle.Bold), Brushes.Black, 100 - offset, 220);
|
||||
g.DrawString((year ?? "?") + " - " + DateTime.Now.Year, new Font("Consolas", 12, FontStyle.Bold), Brushes.Black, 80, 240);
|
||||
|
||||
g.DrawImage(avatar, 80,135);
|
||||
|
||||
g.DrawImage(avatar, 80, 135);
|
||||
g.DrawImage((Image)Resources.rose_overlay, 0, 0);
|
||||
g.Flush();
|
||||
g.Flush();
|
||||
g.Dispose();
|
||||
|
||||
return bm.ToStream(ImageFormat.Png);
|
||||
@ -402,19 +386,19 @@ namespace NadekoBot.Modules.Conversations
|
||||
Bitmap bmp = new Bitmap(100, 100);
|
||||
using (GraphicsPath gp = new GraphicsPath())
|
||||
{
|
||||
gp.AddEllipse(0,0, bmp.Width, bmp.Height);
|
||||
gp.AddEllipse(0, 0, bmp.Width, bmp.Height);
|
||||
using (Graphics gr = Graphics.FromImage(bmp))
|
||||
{
|
||||
gr.SetClip(gp);
|
||||
gr.DrawImage(Image.FromStream(stream), Point.Empty);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
return bmp;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static Func<CommandEventArgs, Task> SayYes()
|
||||
=> async e => await e.Channel.SendMessage("Yes. :)").ConfigureAwait(false);
|
||||
|
@ -4,6 +4,7 @@ using NadekoBot.Classes.Help.Commands;
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Modules.Permissions.Classes;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace NadekoBot.Modules.Help
|
||||
{
|
||||
@ -16,6 +17,8 @@ namespace NadekoBot.Modules.Help
|
||||
}
|
||||
|
||||
public override string Prefix { get; } = NadekoBot.Config.CommandPrefixes.Help;
|
||||
|
||||
|
||||
|
||||
public override void Install(ModuleManager manager)
|
||||
{
|
||||
@ -50,6 +53,37 @@ namespace NadekoBot.Modules.Help
|
||||
await e.Channel.SendMessage("`List of commands:` \n• " + string.Join("\n• ", cmdsArray.Select(c => c.Text)))
|
||||
.ConfigureAwait(false);
|
||||
});
|
||||
cgb.CreateCommand(Prefix + "faq")
|
||||
.Description("Browse the FAQ\n**Usage**: `-faq 1` `-faq Q5`")
|
||||
.Parameter("index", ParameterType.Unparsed)
|
||||
.Do(async e =>
|
||||
{
|
||||
string message = "Something went wrong";
|
||||
string indexString = e.GetArg("index")?.Trim().ToLowerInvariant();
|
||||
Regex questiona = new Regex(@"q(uestion)?\s*(?<number>\d+)");
|
||||
var m = questiona.Match(indexString);
|
||||
if (m.Success)
|
||||
{
|
||||
int index;
|
||||
if (!int.TryParse(m.Groups["number"].Value, out index) || index < 1|| index > NadekoBot.Config.FAQ.Count)
|
||||
{
|
||||
message = "Valid index required";
|
||||
await e.Channel.SendMessage(message).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
var question = NadekoBot.Config.FAQ.Skip(--index).FirstOrDefault();
|
||||
message = Discord.Format.Bold(question.Key) + "\n\n" + Discord.Format.Italics(question.Value);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
int index;
|
||||
if (!int.TryParse(indexString, out index) || index < 0) index =1;
|
||||
message = NadekoBot.Config.FAQ.GetOnPage(--index);
|
||||
}
|
||||
await e.Channel.SendMessage(message).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user