Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clan and login to web, modify a lot about database #30

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deploy/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
web:
image: zzbslayer/kokkoro_bot:latest
ports:
- "5100:5001"
- "5560:5001"
volumes:
- ~/.kokkoro:/root/.kokkoro
command: python3.8 -u /bot/run_web.py
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
web:
image: zzbslayer/kokkoro_bot:latest
ports:
- "5100:5001"
- "5560:5001"
volumes:
- ./:/bot/
- ~/.kokkoro:/root/.kokkoro
Expand Down
5 changes: 4 additions & 1 deletion kokkoro/bot/discord/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ async def kkr_send(self, ev: DiscordEvent, msg: SupportedMessageType, at_sender=

channel = ev.get_channel()
await self._send_by_channel(channel, msg, filename)


@overrides(KokkoroBot)
async def kkr_send_dm(self, ev: DiscordEvent, msg: SupportedMessageType)
await ev.get_author().get_raw_user().send(msg)

@overrides(KokkoroBot)
async def kkr_send_by_group(self, gid, msg: SupportedMessageType, tag=BroadcastTag.default, filename="image.png"):
Expand Down
8 changes: 4 additions & 4 deletions kokkoro/bot/discord/discord_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ def remove_mention_me(raw_message) -> (str, bool):
Pattern in official document is <@![a-z0-9A-Z]+>
e.g. <@!12345>

But the `at` sent by ios discord is <@[a-z0-9A-Z]>
But the `at` sent by iOS discord is <@[a-z0-9A-Z]>
e.g. <@12345>

So temp solution is <@!?[a-z0-9A-Z]+>
'''
dc_at_pattern = r'<@!?[a-z0-9A-Z]+>'
dc_at_pattern = r'<@!?[a-z0-9A-Z]+>'
def normalize_message(raw_message: str) -> str:
"""
规范化 at 信息,"<@!123> waht<@!312>a12" => "@123 waht @312 a12"
Expand All @@ -33,7 +33,7 @@ def normalize_message(raw_message: str) -> str:

def normalize_at(raw_at):
"""
规范化 at 信息,"<@!123>" => " @123 "
规范化 at 信息,"<@!123>" => " @123 "
ios: "<@123>" => " @123 "
"""
return f' @{raw_at[3:-1]} ' if '!' in raw_at else f' @{raw_at[2:-1]} '
return f' @{raw_at[3:-1]} ' if '!' in raw_at else f' @{raw_at[2:-1]} '
5 changes: 4 additions & 1 deletion kokkoro/common_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ def kkr_event_adaptor(self, raw_event) -> EventInterface:
async def kkr_send(self, ev: EventInterface, msg: SupportedMessageType, at_sender=False, filename="image.png"):
raise NotImplementedError

async def kkr_send_dm(self, ev: EventInterface, msg: SupportedMessageType):
raise NotImplementedError

async def kkr_send_by_group(self, gid, msg: SupportedMessageType, tag):
raise NotImplementedError

Expand All @@ -121,4 +124,4 @@ def get_groups(self) -> List[GroupInterface]:
raise NotImplementedError

def get_members_in_group(self, gid) -> List[UserInterface]:
raise NotImplementedError
raise NotImplementedError
1 change: 1 addition & 0 deletions kokkoro/config_example/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import matplotlib.font_manager as font_manager

from .__bot__ import *
from .__web__ import *

for module in MODULES_ON:
try:
Expand Down
2 changes: 2 additions & 0 deletions kokkoro/config_example/__web__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PUBLIC_ADDRESS="http://DOMAIN_OR_IP_ADDRESS:5560"
PUBLIC_BASEPATH="/"
9 changes: 6 additions & 3 deletions kokkoro/modules/pcrclanbattle/clanbattle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .argparse import ArgParser
from .exception import *

from kokkoro import config
from kokkoro.typing import *
from kokkoro.common_interface import KokkoroBot, EventInterface
from kokkoro.service import Service
Expand All @@ -22,7 +23,7 @@ def cb_cmd(prefixes, parser:ArgParser) -> Callable:
prefixes = cb_prefix(prefixes)
if not isinstance(prefixes, Iterable):
raise ValueError('`name` of cb_cmd must be `str` or `Iterable[str]`')

def deco(func):
@wraps(func)
async def wrapper(bot: KokkoroBot, ev: EventInterface):
Expand All @@ -43,7 +44,9 @@ async def wrapper(bot: KokkoroBot, ev: EventInterface):
return deco


from .cmdv2 import *
from .cmd_battle import *
if config.ENABLE_WEB:
from .cmd_web import *


QUICK_START = f'''
Expand Down Expand Up @@ -105,4 +108,4 @@ async def cb_help(bot: KokkoroBot, ev:EventInterface):
# content='命令一览表')
# await session.send(msg)

from . import report
from . import report
Loading