.crca added. If you enable it on a custom reation, you can use the trigger word anywhere in the sentence in order to trigger that custom reaction.
This commit is contained in:
parent
1aa86937c8
commit
f773b0c6b6
1682
src/NadekoBot/Migrations/20170722074959_cr-ca.Designer.cs
generated
Normal file
1682
src/NadekoBot/Migrations/20170722074959_cr-ca.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
25
src/NadekoBot/Migrations/20170722074959_cr-ca.cs
Normal file
25
src/NadekoBot/Migrations/20170722074959_cr-ca.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace NadekoBot.Migrations
|
||||
{
|
||||
public partial class crca : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "ContainsAnywhere",
|
||||
table: "CustomReactions",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ContainsAnywhere",
|
||||
table: "CustomReactions");
|
||||
}
|
||||
}
|
||||
}
|
@ -361,6 +361,8 @@ namespace NadekoBot.Migrations
|
||||
|
||||
b.Property<bool>("AutoDeleteTrigger");
|
||||
|
||||
b.Property<bool>("ContainsAnywhere");
|
||||
|
||||
b.Property<DateTime?>("DateAdded");
|
||||
|
||||
b.Property<bool>("DmResponse");
|
||||
|
@ -270,7 +270,7 @@ namespace NadekoBot.Modules.CustomReactions
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
public async Task CrDm(int id)
|
||||
public async Task CrCa(int id)
|
||||
{
|
||||
if ((Context.Guild == null && !_creds.IsOwner(Context.User)) ||
|
||||
(Context.Guild != null && !((IGuildUser)Context.User).GuildPermissions.Administrator))
|
||||
@ -297,21 +297,21 @@ namespace NadekoBot.Modules.CustomReactions
|
||||
return;
|
||||
}
|
||||
|
||||
var setValue = reaction.DmResponse = !reaction.DmResponse;
|
||||
var setValue = reaction.ContainsAnywhere = !reaction.ContainsAnywhere;
|
||||
|
||||
using (var uow = _db.UnitOfWork)
|
||||
{
|
||||
uow.CustomReactions.Get(id).DmResponse = setValue;
|
||||
uow.CustomReactions.Get(id).ContainsAnywhere = setValue;
|
||||
uow.Complete();
|
||||
}
|
||||
|
||||
if (setValue)
|
||||
{
|
||||
await ReplyConfirmLocalized("crdm_enabled", Format.Code(reaction.Id.ToString())).ConfigureAwait(false);
|
||||
await ReplyConfirmLocalized("crca_enabled", Format.Code(reaction.Id.ToString())).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
await ReplyConfirmLocalized("crdm_disabled", Format.Code(reaction.Id.ToString())).ConfigureAwait(false);
|
||||
await ReplyConfirmLocalized("crca_disabled", Format.Code(reaction.Id.ToString())).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -69,7 +69,13 @@ namespace NadekoBot.Modules.CustomReactions.Services
|
||||
|
||||
var hasTarget = cr.Response.ToLowerInvariant().Contains("%target%");
|
||||
var trigger = cr.TriggerWithContext(umsg, _client).Trim().ToLowerInvariant();
|
||||
return ((hasTarget && content.StartsWith(trigger + " ")) || (_bc.BotConfig.CustomReactionsStartWith && content.StartsWith(trigger + " ")) || content == trigger);
|
||||
return ((cr.ContainsAnywhere &&
|
||||
(content.StartsWith(trigger + " ")
|
||||
|| content.EndsWith(" " + trigger)
|
||||
|| content.Contains(" " + trigger + " ")))
|
||||
|| (hasTarget && content.StartsWith(trigger + " "))
|
||||
|| (_bc.BotConfig.CustomReactionsStartWith && content.StartsWith(trigger + " "))
|
||||
|| content == trigger);
|
||||
}).ToArray();
|
||||
|
||||
if (rs.Length != 0)
|
||||
|
@ -3249,6 +3249,15 @@
|
||||
<data name="crdm_usage" xml:space="preserve">
|
||||
<value>`{0}crdm 44`</value>
|
||||
</data>
|
||||
<data name="crca_cmd" xml:space="preserve">
|
||||
<value>crca</value>
|
||||
</data>
|
||||
<data name="crca_desc" xml:space="preserve">
|
||||
<value>Toggles whether the custom reaction will trigger if the triggering message contains the keyword (instead of only starting with it).</value>
|
||||
</data>
|
||||
<data name="crca_usage" xml:space="preserve">
|
||||
<value>`{0}crca 44`</value>
|
||||
</data>
|
||||
<data name="aliaslist_cmd" xml:space="preserve">
|
||||
<value>aliaslist cmdmaplist aliases</value>
|
||||
</data>
|
||||
|
@ -17,6 +17,8 @@ namespace NadekoBot.Services.Database.Models
|
||||
public bool DmResponse { get; set; }
|
||||
|
||||
public bool IsGlobal => !GuildId.HasValue;
|
||||
|
||||
public bool ContainsAnywhere { get; set; }
|
||||
}
|
||||
|
||||
public class ReactionResponse : DbEntity
|
||||
|
@ -734,6 +734,8 @@
|
||||
"customreactions_crad_enabled": "Message triggering the custom reaction with id {0} will get automatically deleted.",
|
||||
"customreactions_crdm_disabled": "Response message for the custom reaction with id {0} won't be sent as a DM.",
|
||||
"customreactions_crdm_enabled": "Response message for the custom reaction with id {0} will be sent as a DM.",
|
||||
"customreactions_crca_disabled": "Custom reaction with id {0} will no longer trigger unless it's trigger word is at the beggining of the sentence.",
|
||||
"customreactions_crca_enabled": "Custom reaction with id {0} will now trigger if it's contained anywhere in the sentence.",
|
||||
"utility_aliases_none": "No alias found",
|
||||
"utility_alias_added": "Typing {0} will now be an alias of {1}.",
|
||||
"utility_alias_list": "List of aliases",
|
||||
|
Loading…
Reference in New Issue
Block a user