Add comeatmebro etc

This commit is contained in:
appelemac 2016-03-25 09:54:31 +01:00
parent aa589dbc05
commit ff039b8ee4

View File

@ -1,4 +1,4 @@
using Discord;
using Discord;
using Discord.Commands;
using Discord.Modules;
using System;
@ -14,28 +14,49 @@ using NadekoBot.Extensions;
using NadekoBot.Properties;
using NadekoBot.Commands;
namespace NadekoBot.Modules {
internal class Conversations : DiscordModule {
namespace NadekoBot.Modules
{
internal class Conversations : DiscordModule
{
private const string firestr = "🔥 ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้ 🔥";
public Conversations() {
public Conversations()
{
commands.Add(new CopyCommand(this));
commands.Add(new RequestsCommand(this));
}
public override string Prefix { get; } = String.Format(NadekoBot.Config.CommandPrefixes.Conversations, NadekoBot.Creds.BotId);
public override void Install(ModuleManager manager) {
public override void Install(ModuleManager manager)
{
var rng = new Random();
manager.CreateCommands("", cgb => {
manager.CreateCommands("", cgb =>
{
cgb.AddCheck(Classes.Permissions.PermissionChecker.Instance);
cgb.CreateCommand("e")
.Description("You did it.")
.Do(async e => {
.Do(async e =>
{
await e.Channel.SendMessage($"{e.User.Name} did it. 😒 🔫");
});
cgb.CreateCommand("comeatmebro")
.Description("Come at me bro (ง’̀-‘́)ง \n**Usage**: comeatmebro {target}")
.Parameter("target", ParameterType.Optional)
.Do(async e =>
{
var usr = e.Server.FindUsers(e.GetArg("target")).FirstOrDefault();
if (usr == null)
{
await e.Channel.SendMessage("(ง’̀-‘́)ง");
return;
}
await e.Channel.SendMessage($"{usr.Mention} (ง’̀-‘́)ง");
});
cgb.CreateCommand("\\o\\")
.Description("Nadeko replies with /o/")
.Do(async e => await e.Channel.SendMessage(e.User.Mention + "/o/"));
@ -44,16 +65,27 @@ namespace NadekoBot.Modules {
.Description("Nadeko replies with \\o\\")
.Do(async e => await e.Channel.SendMessage(e.User.Mention + "\\o\\"));
cgb.CreateCommand("moveto")
.Description("Suggests moving the conversation.\n**Usage**: moveto #spam")
.Parameter("target", ParameterType.Unparsed)
.Do(async e =>
{
await e.Channel.SendMessage($"(👉 ͡° ͜ʖ ͡°)👉 {e.GetArg("target")}");
});
cgb.CreateCommand("..")
.Description("Adds a new quote with the specified name (single word) and message (no limit).\n**Usage**: .. abc My message")
.Parameter("keyword", ParameterType.Required)
.Parameter("text", ParameterType.Unparsed)
.Do(async e => {
.Do(async e =>
{
var text = e.GetArg("text");
if (string.IsNullOrWhiteSpace(text))
return;
await Task.Run(() =>
Classes.DbHandler.Instance.InsertData(new Classes._DataModels.UserQuote() {
Classes.DbHandler.Instance.InsertData(new Classes._DataModels.UserQuote()
{
DateAdded = DateTime.Now,
Keyword = e.GetArg("keyword").ToLowerInvariant(),
Text = text,
@ -66,7 +98,8 @@ namespace NadekoBot.Modules {
cgb.CreateCommand("...")
.Description("Shows a random quote with a specified name.\n**Usage**: .. abc")
.Parameter("keyword", ParameterType.Required)
.Do(async e => {
.Do(async e =>
{
var keyword = e.GetArg("keyword")?.ToLowerInvariant();
if (string.IsNullOrWhiteSpace(keyword))
return;
@ -82,7 +115,8 @@ namespace NadekoBot.Modules {
});
});
manager.CreateCommands(NadekoBot.BotMention, cgb => {
manager.CreateCommands(NadekoBot.BotMention, cgb =>
{
var client = manager.Client;
cgb.AddCheck(Classes.Permissions.PermissionChecker.Instance);
@ -91,7 +125,8 @@ namespace NadekoBot.Modules {
cgb.CreateCommand("uptime")
.Description("Shows how long Nadeko has been running for.")
.Do(async e => {
.Do(async e =>
{
var time = (DateTime.Now - Process.GetCurrentProcess().StartTime);
var str = string.Format("I have been running for {0} days, {1} hours, and {2} minutes.", time.Days, time.Hours, time.Minutes);
await e.Channel.SendMessage(str);
@ -99,12 +134,15 @@ namespace NadekoBot.Modules {
cgb.CreateCommand("die")
.Description("Works only for the owner. Shuts the bot down.")
.Do(async e => {
if (NadekoBot.IsOwner(e.User.Id)) {
.Do(async e =>
{
if (NadekoBot.IsOwner(e.User.Id))
{
await e.Channel.SendMessage(e.User.Mention + ", Yes, my love.");
await Task.Delay(5000);
Environment.Exit(0);
} else
}
else
await e.Channel.SendMessage(e.User.Mention + ", No.");
});
@ -113,7 +151,8 @@ namespace NadekoBot.Modules {
cgb.CreateCommand("do you love me")
.Description("Replies with positive answer only to the bot owner.")
.Do(async e => {
.Do(async e =>
{
if (NadekoBot.IsOwner(e.User.Id))
await e.Channel.SendMessage(e.User.Mention + ", Of course I do, my Master.");
else
@ -122,15 +161,20 @@ namespace NadekoBot.Modules {
cgb.CreateCommand("how are you")
.Description("Replies positive only if bot owner is online.")
.Do(async e => {
if (NadekoBot.IsOwner(e.User.Id)) {
.Do(async e =>
{
if (NadekoBot.IsOwner(e.User.Id))
{
await e.Channel.SendMessage(e.User.Mention + " I am great as long as you are here.");
return;
}
var kw = e.Server.GetUser(NadekoBot.Creds.OwnerIds[0]);
if (kw != null && kw.Status == UserStatus.Online) {
if (kw != null && kw.Status == UserStatus.Online)
{
await e.Channel.SendMessage(e.User.Mention + " I am great as long as " + kw.Mention + " is with me.");
} else {
}
else
{
await e.Channel.SendMessage(e.User.Mention + " I am sad. My Master is not with me.");
}
});
@ -138,14 +182,17 @@ namespace NadekoBot.Modules {
cgb.CreateCommand("insult")
.Parameter("mention", ParameterType.Required)
.Description("Insults @X person.\n**Usage**: @NadekoBot insult @X.")
.Do(async e => {
.Do(async e =>
{
var u = e.Channel.FindUsers(e.GetArg("mention")).FirstOrDefault();
if (u == null) {
if (u == null)
{
await e.Channel.SendMessage("Invalid user specified.");
return;
}
if (NadekoBot.IsOwner(u.Id)) {
if (NadekoBot.IsOwner(u.Id))
{
await e.Channel.SendMessage("I would never insult my master <3");
return;
}
@ -155,15 +202,18 @@ namespace NadekoBot.Modules {
cgb.CreateCommand("praise")
.Description("Praises @X person.\n**Usage**: @NadekoBot praise @X.")
.Parameter("mention", ParameterType.Required)
.Do(async e => {
.Do(async e =>
{
var u = e.Channel.FindUsers(e.GetArg("mention")).FirstOrDefault();
if (u == null) {
if (u == null)
{
await e.Channel.SendMessage("Invalid user specified.");
return;
}
if (NadekoBot.IsOwner(u.Id)) {
if (NadekoBot.IsOwner(u.Id))
{
await e.Channel.SendMessage(e.User.Mention + " I don't need your permission to praise my beloved Master <3");
return;
}
@ -173,48 +223,61 @@ namespace NadekoBot.Modules {
cgb.CreateCommand("pat")
.Description("Pat someone ^_^")
.Parameter("user", ParameterType.Unparsed)
.Do(async e => {
.Do(async e =>
{
var userStr = e.GetArg("user");
if (string.IsNullOrWhiteSpace(userStr) || !e.Message.MentionedUsers.Any()) return;
var user = e.Server.FindUsers(userStr).FirstOrDefault();
if (user == null)
return;
try {
try
{
await e.Channel.SendMessage(
$"{user.Mention} " +
$"{NadekoBot.Config.PatResponses[rng.Next(0, NadekoBot.Config.PatResponses.Length)]}");
} catch {
}
catch
{
await e.Channel.SendMessage("Error while handling PatResponses check your data/config.json");
}
});
cgb.CreateCommand("cry")
.Description("Tell Nadeko to cry. You are a heartless monster if you use this command.")
.Do(async e => {
try {
.Do(async e =>
{
try
{
await
e.Channel.SendMessage(
$"(•̥́ _•ૅ。)\n{NadekoBot.Config.CryResponses[rng.Next(0, NadekoBot.Config.CryResponses.Length)]}");
} catch {
}
catch
{
await e.Channel.SendMessage("Error while handling CryResponses check your data/config.json");
}
});
cgb.CreateCommand("disguise")
.Description("Tell Nadeko to disguise herself.")
.Do(async e => {
try {
.Do(async e =>
{
try
{
await
e.Channel.SendMessage(
$"{NadekoBot.Config.DisguiseResponses[rng.Next(0, NadekoBot.Config.DisguiseResponses.Length)]}");
} catch {
}
catch
{
await e.Channel.SendMessage("Error while handling DisguiseResponses check your data/config.json");
}
});
cgb.CreateCommand("are you real")
.Description("Useless.")
.Do(async e => {
.Do(async e =>
{
await e.Channel.SendMessage(e.User.Mention + " I will be soon.");
});
@ -225,24 +288,28 @@ namespace NadekoBot.Modules {
cgb.CreateCommand("draw")
.Description("Nadeko instructs you to type $draw. Gambling functions start with $")
.Do(async e => {
.Do(async e =>
{
await e.Channel.SendMessage("Sorry, I don't gamble, type $draw for that function.");
});
cgb.CreateCommand("fire")
.Description("Shows a unicode fire message. Optional parameter [x] tells her how many times to repeat the fire.\n**Usage**: @NadekoBot fire [x]")
.Parameter("times", ParameterType.Optional)
.Do(async e => {
.Do(async e =>
{
var count = 1;
int.TryParse(e.Args[0], out count);
if (count == 0)
count = 1;
if (count < 1 || count > 12) {
if (count < 1 || count > 12)
{
await e.Channel.SendMessage("Number must be between 0 and 12");
return;
}
var str = "";
for (var i = 0; i < count; i++) {
for (var i = 0; i < count; i++)
{
str += firestr;
}
await e.Channel.SendMessage(str);
@ -252,7 +319,8 @@ namespace NadekoBot.Modules {
.Description("Shows a grave image of someone with a start year\n**Usage**: @NadekoBot rip @Someone 2000")
.Parameter("user", ParameterType.Required)
.Parameter("year", ParameterType.Optional)
.Do(async e => {
.Do(async e =>
{
if (string.IsNullOrWhiteSpace(e.GetArg("user")))
return;
var usr = e.Channel.FindUsers(e.GetArg("user")).FirstOrDefault();
@ -262,16 +330,22 @@ namespace NadekoBot.Modules {
e.Channel.SendFile("ripzor_m8.png",
RipName(text, string.IsNullOrWhiteSpace(e.GetArg("year")) ? null : e.GetArg("year")));
});
if (!NadekoBot.Config.DontJoinServers) {
if (!NadekoBot.Config.DontJoinServers)
{
cgb.CreateCommand("j")
.Description("Joins a server using a code.")
.Parameter("id", ParameterType.Required)
.Do(async e => {
.Do(async e =>
{
var invite = await client.GetInvite(e.Args[0]);
if (invite != null) {
try {
if (invite != null)
{
try
{
await invite.Accept();
} catch {
}
catch
{
await e.Channel.SendMessage("Failed to accept invite.");
}
await e.Channel.SendMessage("I got in!");
@ -283,7 +357,8 @@ namespace NadekoBot.Modules {
cgb.CreateCommand("slm")
.Description("Shows the message where you were last mentioned in this channel (checks last 10k messages)")
.Do(async e => {
.Do(async e =>
{
Message msg = null;
var msgs = (await e.Channel.DownloadMessages(100))
@ -291,10 +366,12 @@ namespace NadekoBot.Modules {
.OrderByDescending(m => m.Timestamp);
if (msgs.Any())
msg = msgs.First();
else {
else
{
var attempt = 0;
Message lastMessage = null;
while (msg == null && attempt++ < 5) {
while (msg == null && attempt++ < 5)
{
var msgsarr = await e.Channel.DownloadMessages(100, lastMessage?.Id);
msg = msgsarr
.Where(m => m.MentionedUsers.Contains(e.User))
@ -312,9 +389,11 @@ namespace NadekoBot.Modules {
cgb.CreateCommand("bb")
.Description("Says bye to someone.\n**Usage**: @NadekoBot bb @X")
.Parameter("ppl", ParameterType.Unparsed)
.Do(async e => {
.Do(async e =>
{
var str = "Bye";
foreach (var u in e.Message.MentionedUsers) {
foreach (var u in e.Message.MentionedUsers)
{
if (u.Id != NadekoBot.Client.CurrentUser.Id)
str += " " + u.Mention;
}
@ -324,13 +403,16 @@ namespace NadekoBot.Modules {
cgb.CreateCommand("call")
.Description("Useless. Writes calling @X to chat.\n**Usage**: @NadekoBot call @X ")
.Parameter("who", ParameterType.Required)
.Do(async e => {
.Do(async e =>
{
await e.Channel.SendMessage("Calling " + e.Args[0] + "...");
});
cgb.CreateCommand("hide")
.Description("Hides Nadeko in plain sight!11!!")
.Do(async e => {
using (var ms = Resources.hidden.ToStream(ImageFormat.Png)) {
.Do(async e =>
{
using (var ms = Resources.hidden.ToStream(ImageFormat.Png))
{
await client.CurrentUser.Edit(NadekoBot.Creds.Password, avatar: ms);
}
await e.Channel.SendMessage("*hides*");
@ -338,8 +420,10 @@ namespace NadekoBot.Modules {
cgb.CreateCommand("unhide")
.Description("Unhides Nadeko in plain sight!1!!1")
.Do(async e => {
using (var fs = new FileStream("data/avatar.png", FileMode.Open)) {
.Do(async e =>
{
using (var fs = new FileStream("data/avatar.png", FileMode.Open))
{
await client.CurrentUser.Edit(NadekoBot.Creds.Password, avatar: fs);
}
await e.Channel.SendMessage("*unhides*");
@ -347,17 +431,22 @@ namespace NadekoBot.Modules {
cgb.CreateCommand("dump")
.Description("Dumps all of the invites it can to dump.txt.** Owner Only.**")
.Do(async e => {
.Do(async e =>
{
if (!NadekoBot.IsOwner(e.User.Id)) return;
var i = 0;
var j = 0;
var invites = "";
foreach (var s in client.Servers) {
try {
foreach (var s in client.Servers)
{
try
{
var invite = await s.CreateInvite(0);
invites += invite.Url + "\n";
i++;
} catch {
}
catch
{
j++;
continue;
}
@ -368,11 +457,13 @@ namespace NadekoBot.Modules {
cgb.CreateCommand("ab")
.Description("Try to get 'abalabahaha'")
.Do(async e => {
.Do(async e =>
{
string[] strings = { "ba", "la", "ha" };
var construct = "@a";
var cnt = rng.Next(4, 7);
while (cnt-- > 0) {
while (cnt-- > 0)
{
construct += strings[rng.Next(0, strings.Length)];
}
await e.Channel.SendMessage(construct + "~");
@ -381,9 +472,11 @@ namespace NadekoBot.Modules {
cgb.CreateCommand("av").Alias("avatar")
.Parameter("mention", ParameterType.Required)
.Description("Shows a mentioned person's avatar.\n**Usage**: ~av @X")
.Do(async e => {
.Do(async e =>
{
var usr = e.Channel.FindUsers(e.GetArg("mention")).FirstOrDefault();
if (usr == null) {
if (usr == null)
{
await e.Channel.SendMessage("Invalid user specified.");
return;
}
@ -391,10 +484,10 @@ namespace NadekoBot.Modules {
});
cgb.CreateCommand("leet")
.Description("Convert your text to leetspeak. Level is a number 1-6.\n**Usage**: @BotName leet [level] [Your text here]")
.Parameter("level", ParameterType.Required)
.Parameter("text", ParameterType.Unparsed)
.Do(async e => {
.Do(async e =>
{
var text = e.GetArg("text")?.Trim();
var levelStr = e.GetArg("level")?.Trim();
int level;
@ -408,14 +501,16 @@ namespace NadekoBot.Modules {
});
}
public Stream RipName(string name, string year = null) {
public Stream RipName(string name, string year = null)
{
var bm = Resources.rip;
var offset = name.Length * 5;
var fontSize = 20;
if (name.Length > 10) {
if (name.Length > 10)
{
fontSize -= (name.Length - 10) / 2;
}