Merge branch '1.0' of github.com:Kwoth/NadekoBot into 0.9-to-1.0-migration

This commit is contained in:
Nitix 2016-10-05 02:03:09 +02:00
commit 6ff8fec2c5
6 changed files with 106 additions and 203 deletions

View File

@ -529,41 +529,41 @@ namespace NadekoBot.Modules.Administration
await channel.SendMessageAsync($"`Logging will no longer ignore {channel.Name} ({channel.Id}) channel.`").ConfigureAwait(false); await channel.SendMessageAsync($"`Logging will no longer ignore {channel.Name} ({channel.Id}) channel.`").ConfigureAwait(false);
} }
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias] //[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
[RequireContext(ContextType.Guild)] //[RequireContext(ContextType.Guild)]
[OwnerOnly] //[OwnerOnly]
public async Task LogAdd(IUserMessage msg, [Remainder] string eventName) //public async Task LogAdd(IUserMessage msg, [Remainder] string eventName)
{ //{
var channel = (ITextChannel)msg.Channel; // var channel = (ITextChannel)msg.Channel;
//eventName = eventName?.Replace(" ","").ToLowerInvariant(); // //eventName = eventName?.Replace(" ","").ToLowerInvariant();
switch (eventName.ToLowerInvariant()) // switch (eventName.ToLowerInvariant())
{ // {
case "messagereceived": // case "messagereceived":
case "messageupdated": // case "messageupdated":
case "messagedeleted": // case "messagedeleted":
case "userjoined": // case "userjoined":
case "userleft": // case "userleft":
case "userbanned": // case "userbanned":
case "userunbanned": // case "userunbanned":
case "channelcreated": // case "channelcreated":
case "channeldestroyed": // case "channeldestroyed":
case "channelupdated": // case "channelupdated":
using (var uow = DbHandler.UnitOfWork()) // using (var uow = DbHandler.UnitOfWork())
{ // {
var logSetting = uow.GuildConfigs.For(channel.Guild.Id).LogSetting; // var logSetting = uow.GuildConfigs.For(channel.Guild.Id).LogSetting;
GuildLogSettings.AddOrUpdate(channel.Guild.Id, (id) => logSetting, (id, old) => logSetting); // GuildLogSettings.AddOrUpdate(channel.Guild.Id, (id) => logSetting, (id, old) => logSetting);
var prop = logSetting.GetType().GetProperty(eventName); // var prop = logSetting.GetType().GetProperty(eventName);
prop.SetValue(logSetting, true); // prop.SetValue(logSetting, true);
await uow.CompleteAsync().ConfigureAwait(false); // await uow.CompleteAsync().ConfigureAwait(false);
} // }
await channel.SendMessageAsync($"`Now logging {eventName} event.`").ConfigureAwait(false); // await channel.SendMessageAsync($"`Now logging {eventName} event.`").ConfigureAwait(false);
break; // break;
default: // default:
await channel.SendMessageAsync($"`Event \"{eventName}\" not found.`").ConfigureAwait(false); // await channel.SendMessageAsync($"`Event \"{eventName}\" not found.`").ConfigureAwait(false);
break; // break;
} // }
} //}
//[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] //[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
//[RequireContext(ContextType.Guild)] //[RequireContext(ContextType.Guild)]

View File

@ -94,27 +94,6 @@ namespace NadekoBot.Modules.Searches
} }
public List<ConvertUnit> Units { get; set; } public List<ConvertUnit> Units { get; set; }
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
[RequireContext(ContextType.Guild)]
public async Task ConvertListE(IUserMessage msg) //extended and bugged list
{
var channel = msg.Channel as IGuildChannel;
var sb = new StringBuilder("Units that can be used by the converter: \n");
var res = Units.GroupBy(x => x.UnitType);
foreach (var group in res)
{
sb.AppendLine($"{group.Key}: ```xl");
foreach (var el in group)
{
sb.Append($" [{string.Join(",", el.Triggers)}] ");
}
sb.AppendLine("```");
}
await msg.ReplyLong(sb.ToString(), breakOn: new[] { "```xl", "\n" });
}
[LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias] [LocalizedCommand, LocalizedRemarks, LocalizedSummary, LocalizedAlias]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task ConvertList(IUserMessage msg) public async Task ConvertList(IUserMessage msg)
@ -176,7 +155,6 @@ namespace NadekoBot.Modules.Searches
} }
else else
{ {
//I just love currency
if (originUnit.UnitType == "currency") if (originUnit.UnitType == "currency")
{ {
res = (value * targetUnit.Modifier) / originUnit.Modifier; res = (value * targetUnit.Modifier) / originUnit.Modifier;

View File

@ -141,7 +141,7 @@ namespace NadekoBot.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Adds a new quote with the specified name and message (no limit).. /// Looks up a localized string similar to Adds a new quote with the specified name and message..
/// </summary> /// </summary>
public static string addquote_desc { public static string addquote_desc {
get { get {
@ -150,7 +150,7 @@ namespace NadekoBot.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to `.. abc sayhi Hi`. /// Looks up a localized string similar to `.. sayhi Hi`.
/// </summary> /// </summary>
public static string addquote_summary { public static string addquote_summary {
get { get {
@ -1031,60 +1031,6 @@ namespace NadekoBot.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Checks if a certain user is streaming on the beam platform..
/// </summary>
public static string checkbeam_desc {
get {
return ResourceManager.GetString("checkbeam_desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to `~chbm SomeStreamer`.
/// </summary>
public static string checkbeam_summary {
get {
return ResourceManager.GetString("checkbeam_summary", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to checkbeam chbm.
/// </summary>
public static string checkbeam_text {
get {
return ResourceManager.GetString("checkbeam_text", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Checks if a certain user is streaming on the hitbox platform..
/// </summary>
public static string checkhitbox_desc {
get {
return ResourceManager.GetString("checkhitbox_desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to `~chhb SomeStreamer`.
/// </summary>
public static string checkhitbox_summary {
get {
return ResourceManager.GetString("checkhitbox_summary", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to checkhitbox chhb.
/// </summary>
public static string checkhitbox_text {
get {
return ResourceManager.GetString("checkhitbox_text", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Checks your userspecific permissions on this channel.. /// Looks up a localized string similar to Checks your userspecific permissions on this channel..
/// </summary> /// </summary>
@ -1113,29 +1059,29 @@ namespace NadekoBot.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Checks if a certain user is streaming on the twitch platform.. /// Looks up a localized string similar to Checks if a user is online on a certain streaming platform..
/// </summary> /// </summary>
public static string checktwitch_desc { public static string checkstream_desc {
get { get {
return ResourceManager.GetString("checktwitch_desc", resourceCulture); return ResourceManager.GetString("checkstream_desc", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to `~chtw SomeStreamer`. /// Looks up a localized string similar to `~cs twitch MyFavStreamer`.
/// </summary> /// </summary>
public static string checktwitch_summary { public static string checkstream_summary {
get { get {
return ResourceManager.GetString("checktwitch_summary", resourceCulture); return ResourceManager.GetString("checkstream_summary", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to checktwitch chtw. /// Looks up a localized string similar to checkstream cs.
/// </summary> /// </summary>
public static string checktwitch_text { public static string checkstream_text {
get { get {
return ResourceManager.GetString("checktwitch_text", resourceCulture); return ResourceManager.GetString("checkstream_text", resourceCulture);
} }
} }
@ -3840,7 +3786,7 @@ namespace NadekoBot.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Toggles logging in this channel. Logs every message sent/deleted/edited on the server. **Bot Owner Only!**. /// Looks up a localized string similar to Logs server activity in this channel..
/// </summary> /// </summary>
public static string logserver_desc { public static string logserver_desc {
get { get {
@ -4470,7 +4416,7 @@ namespace NadekoBot.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to `~osu top5 Name`. /// Looks up a localized string similar to `~osu5 Name`.
/// </summary> /// </summary>
public static string osu5_summary { public static string osu5_summary {
get { get {
@ -6647,33 +6593,6 @@ namespace NadekoBot.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Starts a game of trivia. You can add nohint to prevent hints.First player to get to 10 points wins by default. You can specify a different number. 30 seconds per question..
/// </summary>
public static string t_desc {
get {
return ResourceManager.GetString("t_desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to `&gt;t nohint` or `&gt;t 5 nohint`.
/// </summary>
public static string t_summary {
get {
return ResourceManager.GetString("t_summary", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to trivia t.
/// </summary>
public static string t_text {
get {
return ResourceManager.GetString("t_text", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Takes a certain amount of flowers from someone. **Bot Owner Only!**. /// Looks up a localized string similar to Takes a certain amount of flowers from someone. **Bot Owner Only!**.
/// </summary> /// </summary>
@ -6836,6 +6755,33 @@ namespace NadekoBot.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Starts a game of trivia. You can add nohint to prevent hints.First player to get to 10 points wins by default. You can specify a different number. 30 seconds per question..
/// </summary>
public static string trivia_desc {
get {
return ResourceManager.GetString("trivia_desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to `&gt;t nohint` or `&gt;t 5 nohint`.
/// </summary>
public static string trivia_summary {
get {
return ResourceManager.GetString("trivia_summary", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to trivia t.
/// </summary>
public static string trivia_text {
get {
return ResourceManager.GetString("trivia_text", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Notifies this channel when a certain user starts streaming.. /// Looks up a localized string similar to Notifies this channel when a certain user starts streaming..
/// </summary> /// </summary>

View File

@ -238,7 +238,7 @@
<value>logserver</value> <value>logserver</value>
</data> </data>
<data name="logserver_desc" xml:space="preserve"> <data name="logserver_desc" xml:space="preserve">
<value>Toggles logging in this channel. Logs every message sent/deleted/edited on the server. **Bot Owner Only!**</value> <value>Logs server activity in this channel.</value>
</data> </data>
<data name="logserver_summary" xml:space="preserve"> <data name="logserver_summary" xml:space="preserve">
<value>`.logserver`</value> <value>`.logserver`</value>
@ -1264,10 +1264,10 @@
<value>.</value> <value>.</value>
</data> </data>
<data name="addquote_desc" xml:space="preserve"> <data name="addquote_desc" xml:space="preserve">
<value>Adds a new quote with the specified name and message (no limit).</value> <value>Adds a new quote with the specified name and message.</value>
</data> </data>
<data name="addquote_summary" xml:space="preserve"> <data name="addquote_summary" xml:space="preserve">
<value>`.. abc sayhi Hi`</value> <value>`.. sayhi Hi`</value>
</data> </data>
<data name="showquote_text" xml:space="preserve"> <data name="showquote_text" xml:space="preserve">
<value>..</value> <value>..</value>
@ -1467,13 +1467,13 @@
<data name="leaderboard_summary" xml:space="preserve"> <data name="leaderboard_summary" xml:space="preserve">
<value>`$lb`</value> <value>`$lb`</value>
</data> </data>
<data name="t_text" xml:space="preserve"> <data name="trivia_text" xml:space="preserve">
<value>trivia t</value> <value>trivia t</value>
</data> </data>
<data name="t_desc" xml:space="preserve"> <data name="trivia_desc" xml:space="preserve">
<value>Starts a game of trivia. You can add nohint to prevent hints.First player to get to 10 points wins by default. You can specify a different number. 30 seconds per question.</value> <value>Starts a game of trivia. You can add nohint to prevent hints.First player to get to 10 points wins by default. You can specify a different number. 30 seconds per question.</value>
</data> </data>
<data name="t_summary" xml:space="preserve"> <data name="trivia_summary" xml:space="preserve">
<value>`&gt;t nohint` or `&gt;t 5 nohint`</value> <value>`&gt;t nohint` or `&gt;t 5 nohint`</value>
</data> </data>
<data name="tl_text" xml:space="preserve"> <data name="tl_text" xml:space="preserve">
@ -1935,33 +1935,6 @@
<data name="beam_summary" xml:space="preserve"> <data name="beam_summary" xml:space="preserve">
<value>`~beam SomeStreamer`</value> <value>`~beam SomeStreamer`</value>
</data> </data>
<data name="checkhitbox_text" xml:space="preserve">
<value>checkhitbox chhb</value>
</data>
<data name="checkhitbox_desc" xml:space="preserve">
<value>Checks if a certain user is streaming on the hitbox platform.</value>
</data>
<data name="checkhitbox_summary" xml:space="preserve">
<value>`~chhb SomeStreamer`</value>
</data>
<data name="checktwitch_text" xml:space="preserve">
<value>checktwitch chtw</value>
</data>
<data name="checktwitch_desc" xml:space="preserve">
<value>Checks if a certain user is streaming on the twitch platform.</value>
</data>
<data name="checktwitch_summary" xml:space="preserve">
<value>`~chtw SomeStreamer`</value>
</data>
<data name="checkbeam_text" xml:space="preserve">
<value>checkbeam chbm</value>
</data>
<data name="checkbeam_desc" xml:space="preserve">
<value>Checks if a certain user is streaming on the beam platform.</value>
</data>
<data name="checkbeam_summary" xml:space="preserve">
<value>`~chbm SomeStreamer`</value>
</data>
<data name="removestream_text" xml:space="preserve"> <data name="removestream_text" xml:space="preserve">
<value>removestream rms</value> <value>removestream rms</value>
</data> </data>
@ -2041,7 +2014,7 @@
<value>Displays a user's top 5 plays.</value> <value>Displays a user's top 5 plays.</value>
</data> </data>
<data name="osu5_summary" xml:space="preserve"> <data name="osu5_summary" xml:space="preserve">
<value>`~osu top5 Name`</value> <value>`~osu5 Name`</value>
</data> </data>
<data name="pokemon_text" xml:space="preserve"> <data name="pokemon_text" xml:space="preserve">
<value>pokemon poke</value> <value>pokemon poke</value>
@ -2655,4 +2628,13 @@
<data name="migratedata_text" xml:space="preserve"> <data name="migratedata_text" xml:space="preserve">
<value>migratedata</value> <value>migratedata</value>
</data> </data>
<data name="checkstream_desc" xml:space="preserve">
<value>Checks if a user is online on a certain streaming platform.</value>
</data>
<data name="checkstream_summary" xml:space="preserve">
<value>`~cs twitch MyFavStreamer`</value>
</data>
<data name="checkstream_text" xml:space="preserve">
<value>checkstream cs</value>
</data>
</root> </root>

View File

@ -45,16 +45,6 @@ namespace NadekoBot.Services
var guild = (msg.Channel as ITextChannel)?.Guild; var guild = (msg.Channel as ITextChannel)?.Guild;
BlacklistItem blacklistedItem;
if ((blacklistedItem = Permissions.BlacklistCommands.BlacklistedItems.FirstOrDefault(bi =>
(bi.Type == BlacklistItem.BlacklistType.Server && bi.ItemId == guild?.Id) ||
(bi.Type == BlacklistItem.BlacklistType.Channel && bi.ItemId == msg.Channel.Id) ||
(bi.Type == BlacklistItem.BlacklistType.User && bi.ItemId == usrMsg.Author.Id))) != null)
{
_log.Warn("Attempt was made to run a command by a blacklisted {0}, id: {1}", blacklistedItem.Type, blacklistedItem.ItemId);
return;
}
if (guild != null && guild.OwnerId != usrMsg.Author.Id) if (guild != null && guild.OwnerId != usrMsg.Author.Id)
{ {
if (Permissions.FilterCommands.InviteFilteringChannels.Contains(usrMsg.Channel.Id) || if (Permissions.FilterCommands.InviteFilteringChannels.Contains(usrMsg.Channel.Id) ||
@ -73,9 +63,8 @@ namespace NadekoBot.Services
} }
} }
} }
}
if (guild != null && guild.OwnerId != usrMsg.Author.Id)
{
var filteredWords = Permissions.FilterCommands.FilteredWordsForChannel(usrMsg.Channel.Id, guild.Id).Concat(Permissions.FilterCommands.FilteredWordsForServer(guild.Id)); var filteredWords = Permissions.FilterCommands.FilteredWordsForChannel(usrMsg.Channel.Id, guild.Id).Concat(Permissions.FilterCommands.FilteredWordsForServer(guild.Id));
var wordsInMessage = usrMsg.Content.ToLowerInvariant().Split(' '); var wordsInMessage = usrMsg.Content.ToLowerInvariant().Split(' ');
if (filteredWords.Any(w => wordsInMessage.Contains(w))) if (filteredWords.Any(w => wordsInMessage.Contains(w)))
@ -90,6 +79,15 @@ namespace NadekoBot.Services
_log.Warn("I do not have permission to filter words in channel with id " + usrMsg.Channel.Id, ex); _log.Warn("I do not have permission to filter words in channel with id " + usrMsg.Channel.Id, ex);
} }
} }
BlacklistItem blacklistedItem;
if ((blacklistedItem = Permissions.BlacklistCommands.BlacklistedItems.FirstOrDefault(bi =>
(bi.Type == BlacklistItem.BlacklistType.Server && bi.ItemId == guild?.Id) ||
(bi.Type == BlacklistItem.BlacklistType.Channel && bi.ItemId == msg.Channel.Id) ||
(bi.Type == BlacklistItem.BlacklistType.User && bi.ItemId == usrMsg.Author.Id))) != null)
{
return;
}
} }
try try
@ -221,7 +219,7 @@ namespace NadekoBot.Services
if (guild != null) if (guild != null)
{ {
int index; int index;
if (!rootPerm.AsEnumerable().CheckPermissions(message, cmd.Name, cmd.Module.Name, out index)) if (!rootPerm.AsEnumerable().CheckPermissions(message, cmd.Text, cmd.Module.Name, out index))
{ {
var returnMsg = $"Permission number #{index + 1} **{rootPerm.GetAt(index).GetCommand()}** is preventing this action."; var returnMsg = $"Permission number #{index + 1} **{rootPerm.GetAt(index).GetCommand()}** is preventing this action.";
return new Tuple<Command, IResult>(cmd, SearchResult.FromError(CommandError.Exception, returnMsg)); return new Tuple<Command, IResult>(cmd, SearchResult.FromError(CommandError.Exception, returnMsg));
@ -232,7 +230,7 @@ namespace NadekoBot.Services
{ {
if (!((IGuildUser)user).Roles.Any(r => r.Name.Trim().ToLowerInvariant() == permRole)) if (!((IGuildUser)user).Roles.Any(r => r.Name.Trim().ToLowerInvariant() == permRole))
{ {
return new Tuple<Command, IResult>(cmd, SearchResult.FromError(CommandError.Exception, $"You need a **{permRole}** role in order to use permission commands.")); return new Tuple<Command, IResult>(cmd, SearchResult.FromError(CommandError.Exception, $"You need the **{permRole}** role in order to use permission commands."));
} }
} }
} }

View File

@ -12,7 +12,6 @@ namespace NadekoBot.Services.Database.Models
public ulong ChannelId { get; set; } public ulong ChannelId { get; set; }
public HashSet<IgnoredLogChannel> IgnoredChannels { get; set; } public HashSet<IgnoredLogChannel> IgnoredChannels { get; set; }
public bool MessageReceived { get; set; } = true;
public bool MessageUpdated { get; set; } = true; public bool MessageUpdated { get; set; } = true;
public bool MessageDeleted { get; set; } = true; public bool MessageDeleted { get; set; } = true;