|
8 | 8 | from core import utils, EventListener, PersistentReport, Plugin, Report, Status, Side, Player, Coalition, \ |
9 | 9 | Channel, DataObjectFactory, event, chat_command, ServiceRegistry, ChatCommand, get_translation |
10 | 10 | from datetime import datetime, timezone |
| 11 | +from discord import ButtonStyle |
11 | 12 | from discord.ext import tasks |
| 13 | +from discord.ui import View, Button |
12 | 14 | from pathlib import Path |
13 | 15 | from psycopg.rows import dict_row |
14 | 16 | from services.servicebus import ServiceBus |
15 | 17 | from services.bot.dummy import DummyBot |
16 | 18 | from typing import TYPE_CHECKING, Callable, Coroutine |
17 | 19 |
|
18 | 20 | from .menu import read_menu_config, filter_menu |
19 | | -from .views import ProfanityView |
20 | 21 |
|
21 | 22 | if TYPE_CHECKING: |
22 | 23 | from core import Server |
@@ -654,7 +655,49 @@ async def onCensoredPlayerName(self, server: Server, data: dict) -> None: |
654 | 655 | else: |
655 | 656 | message = _("User {} (ucid={})\nPotentially inappropriate nickname.").format( |
656 | 657 | data['name'], data['ucid']) |
657 | | - view = ProfanityView(ucid=data['ucid'], name=data['name']) |
| 658 | + |
| 659 | + view = View(timeout=None) |
| 660 | + # noinspection PyTypeChecker |
| 661 | + button = Button(label="Whitelist", style=ButtonStyle.primary, custom_id=f"whitelist_{data['name']}") |
| 662 | + view.add_item(button) |
| 663 | + # noinspection PyTypeChecker |
| 664 | + button = Button(label="Ban", style=ButtonStyle.red, custom_id=f"ban_profanity_{data['ucid']}") |
| 665 | + view.add_item(button) |
| 666 | + # noinspection PyTypeChecker |
| 667 | + button = Button(label="Cancel", style=ButtonStyle.secondary, custom_id=f"cancel") |
| 668 | + view.add_item(button) |
| 669 | + await admin_channel.send(f"```{message}```", view=view) |
| 670 | + |
| 671 | + @event(name="onBanReject") |
| 672 | + async def onBanReject(self, server: Server, data: dict) -> None: |
| 673 | + admin_channel = self.bot.get_admin_channel(server) |
| 674 | + if not admin_channel: |
| 675 | + return |
| 676 | + message = _('Banned user {name} (ucid={ucid}, ipaddr={ipaddr}) rejected. Reason: {reason}').format( |
| 677 | + name=data['name'], ucid=data['ucid'], ipaddr=data['ipaddr'], reason=data['reason']) |
| 678 | + await admin_channel.send(f"```{message}```") |
| 679 | + |
| 680 | + @event(name="onBanEvade") |
| 681 | + async def onBanEvade(self, server: Server, data: dict) -> None: |
| 682 | + admin_channel = self.bot.get_admin_channel(server) |
| 683 | + if not admin_channel: |
| 684 | + return |
| 685 | + old_name = await self.bot.get_member_or_name_by_ucid(data['old_ucid']) |
| 686 | + if isinstance(old_name, discord.Member): |
| 687 | + old_name = old_name.display_name |
| 688 | + |
| 689 | + message = _('Player {name} (ucid={ucid}) connected from the same IP (ipaddr={ipaddr}) ' |
| 690 | + 'as banned player {old_name} (ucid={old_ucid}), who was banned for {reason}!').format( |
| 691 | + name=data['name'], ucid=data['ucid'], ipaddr=data['ipaddr'], old_name=old_name, |
| 692 | + old_ucid=data['old_ucid'], reason=data['reason'] |
| 693 | + ) |
| 694 | + view = View(timeout=None) |
| 695 | + # noinspection PyTypeChecker |
| 696 | + button = Button(label="Ban", style=ButtonStyle.red, custom_id=f"ban_evade_{data['ucid']}") |
| 697 | + view.add_item(button) |
| 698 | + # noinspection PyTypeChecker |
| 699 | + button = Button(label="Cancel", style=ButtonStyle.secondary, custom_id=f"cancel") |
| 700 | + view.add_item(button) |
658 | 701 | await admin_channel.send(f"```{message}```", view=view) |
659 | 702 |
|
660 | 703 | async def _stop_player(self, server: Server, player: Player): |
|
0 commit comments