Skip to content

Commit 373ae4c

Browse files
committed
Poop user command
1 parent b893aff commit 373ae4c

File tree

4 files changed

+25
-36
lines changed

4 files changed

+25
-36
lines changed

bin/running_on_dart.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ void main(List<String> args) async {
2626
..addCommand(admin)
2727
..addCommand(jellyfin)
2828
..addCommand(reminderMessageCommand)
29+
..addCommand(poopUserCommand)
2930
..addCommand(kavita)
3031
..addConverter(settingsConverter)
3132
..addConverter(manageableTagConverter)

lib/running_on_dart.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ export 'src/commands/info.dart' show info;
44
export 'src/commands/github.dart' show github;
55
export 'src/commands/avatar.dart' show avatar;
66
export 'src/commands/docs.dart' show docs;
7-
export 'src/commands/reminder.dart' show reminder;
8-
export 'src/commands/admin.dart' show admin;
7+
export 'src/commands/reminder.dart' show reminder, reminderMessageCommand;
8+
export 'src/commands/admin.dart' show admin, poopUserCommand;
99
export 'src/commands/jellyfin.dart' show jellyfin;
1010
export 'src/commands/tag.dart' show tag;
11-
export 'src/commands/reminder.dart' show reminderMessageCommand;
1211
export 'src/commands/kavita.dart' show kavita;
1312

1413
export 'src/settings.dart';

lib/src/commands/admin.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@ Stream<Member> searchMembers(String disallowedChar, int batchSize, Guild guild)
1616
);
1717
}
1818

19+
final poopUserCommand = UserCommand("poop-username", (UserContext context) async {
20+
final member = context.targetMember;
21+
if (member == null) {
22+
return context.respond(
23+
MessageBuilder(content: "This command can only be used on guild members."),
24+
level: ResponseLevel.private,
25+
);
26+
}
27+
28+
final poopModule = Injector.appInstance.get<PoopNameModule>();
29+
30+
await poopModule.poopMember(member, dryRun: false);
31+
32+
await context.respond(MessageBuilder(content: "Done..."), level: ResponseLevel.private);
33+
}, checks: [GuildCheck.all(), PermissionsCheck(Permissions.manageNicknames)]);
34+
1935
final admin = ChatGroup(
2036
'admin',
2137
'Administrative commands',

test/poop_name_test.dart

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@ import 'package:running_on_dart/src/modules/poop_name.dart';
44
void main() {
55
group('weirdCharsRegexp', () {
66
test('should catch Mathematical Alphanumeric Symbols (original examples)', () {
7-
final testCases = [
8-
'𝕯𝖗𝖚𝖌𝖘',
9-
'𝕾𝖚𝖌𝖆𝖗𝕾𝖊𝖆𝖓',
10-
'𝸸𝖚𝖗𝖉𝖚𝖍 ♛',
11-
'𝑇𝑟𝑎𝑣𝑖𝑠',
12-
'𝔃𝓲𝓰𝓪',
13-
];
7+
final testCases = ['𝕯𝖗𝖚𝖌𝖘', '𝕾𝖚𝖌𝖆𝖗𝕾𝖊𝖆𝖓', '𝸸𝖚𝖗𝖉𝖚𝖍 ♛', '𝑇𝑟𝑎𝑣𝑖𝑠', '𝔃𝓲𝓰𝓪'];
148

159
for (final testCase in testCases) {
1610
expect(
@@ -39,12 +33,7 @@ void main() {
3933
});
4034

4135
test('should catch excessive currency symbol abuse (3+ symbols)', () {
42-
final testCases = [
43-
'₮₴₹test',
44-
'₮₴₹₽₪test',
45-
'test₮₴₹name',
46-
'₮₴₹₽₪₫₡₢₣₤₥₦₧₨₩₮₯₰₱₲₳₴₵₶₷₸₹₺₻₼₽₾₿',
47-
];
36+
final testCases = ['₮₴₹test', '₮₴₹₽₪test', 'test₮₴₹name', '₮₴₹₽₪₫₡₢₣₤₥₦₧₨₩₮₯₰₱₲₳₴₵₶₷₸₹₺₻₼₽₾₿'];
4837

4938
for (final testCase in testCases) {
5039
expect(
@@ -56,12 +45,7 @@ void main() {
5645
});
5746

5847
test('should NOT catch moderate currency symbol use (1-2 symbols)', () {
59-
final testCases = [
60-
'₮testname',
61-
'test₴name',
62-
'₮test₴',
63-
'user₹name₽',
64-
];
48+
final testCases = ['₮testname', 'test₴name', '₮test₴', 'user₹name₽'];
6549

6650
for (final testCase in testCases) {
6751
expect(
@@ -87,13 +71,7 @@ void main() {
8771
});
8872

8973
test('should preserve existing invisible character detection', () {
90-
final testCases = [
91-
'test\u200Bname',
92-
'name\u202Etext',
93-
'test\u2060name',
94-
'name\uFEFFtext',
95-
'test\u00ADname',
96-
];
74+
final testCases = ['test\u200Bname', 'name\u202Etext', 'test\u2060name', 'name\uFEFFtext', 'test\u00ADname'];
9775

9876
for (final testCase in testCases) {
9977
expect(
@@ -116,7 +94,7 @@ void main() {
11694
'kebab-case-user',
11795
'User123',
11896
'SimpleTest',
119-
'café',
97+
'café',
12098
'naïve',
12199
'résumé',
122100
];
@@ -127,12 +105,7 @@ void main() {
127105
});
128106

129107
test('should catch ASCII control characters', () {
130-
final testCases = [
131-
'test\x00name',
132-
'test\x1Fname',
133-
'test\x7Fname',
134-
'test\x9Fname',
135-
];
108+
final testCases = ['test\x00name', 'test\x1Fname', 'test\x7Fname', 'test\x9Fname'];
136109

137110
for (final testCase in testCases) {
138111
expect(

0 commit comments

Comments
 (0)