Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
OasisAkari committed Sep 20, 2023
1 parent bd918c8 commit 754a647
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 40 deletions.
7 changes: 3 additions & 4 deletions console.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
from bot import init_bot
from core.extra.scheduler import load_extra_schedulers
from core.builtins import PrivateAssets, EnableDirtyWordCheck
from core.types import MsgInfo, AutoSession
from core.console.template import Template as MessageSession
from core.types import MsgInfo, Session
from core.console.message import MessageSession
from core.parser.message import parser
from core.utils.bot import init_async
from core.logger import Logger
Expand Down Expand Up @@ -68,8 +68,7 @@ async def send_command(msg, interactions=None):
target_from='TEST|Console',
sender_from='TEST', client_name='TEST', message_id=0,
reply_id=None),
session=AutoSession(message=msg, target='TEST|Console|0', sender='TEST|0',
auto_interactions=interactions)))
session=Session(message=msg, target='TEST|Console|0', sender='TEST|0')))
# print(returns)
Logger.info('----Process end----')
return returns
Expand Down
37 changes: 14 additions & 23 deletions core/console/template.py → core/console/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from core.builtins.message import MessageSession as MessageSessionT
from core.builtins.message.chain import MessageChain
from core.logger import Logger
from core.types import Session, MsgInfo, FinishedSession as FinS, AutoSession
from core.types import Session, MsgInfo, FinishedSession as FinS


class FinishedSession(FinS):
Expand All @@ -18,8 +18,8 @@ async def delete(self):
print("(Tried to delete message, but I'm a console so I cannot do it :< )")


class Template(MessageSessionT):
session: Union[Session, AutoSession]
class MessageSession(MessageSessionT):
session: Union[Session]

class Feature:
image = True
Expand Down Expand Up @@ -50,12 +50,8 @@ async def wait_confirm(self, message_chain=None, quote=True, delete=True):
if message_chain is not None:
send = await self.send_message(message_chain)
print("(发送“是”或符合确认条件的词语来确认)")
print(self.session.auto_interactions)
if self.session.auto_interactions:
c = self.session.auto_interactions[0]
del self.session.auto_interactions[0]
else:
c = input('Confirm: ')

c = input('Confirm: ')
print(c)
if message_chain is not None and delete:
await send.delete()
Expand All @@ -68,11 +64,7 @@ async def wait_anyone(self, message_chain=None, quote=True, delete=True):
send = None
if message_chain is not None:
send = await self.send_message(message_chain)
if self.session.auto_interactions:
c = self.session.auto_interactions[0]
del self.session.auto_interactions[0]
else:
c = input('Confirm: ')
c = input('Confirm: ')
print(c)
if message_chain is not None and delete:
await send.delete()
Expand All @@ -85,14 +77,13 @@ async def wait_reply(self, message_chain, quote=True, all_=False, append_instruc
message_chain.append(Plain(self.locale.t("message.reply.prompt")))
send = await self.send_message(message_chain, quote)
c = input('Reply: ')
return Template(target=MsgInfo(target_id='TEST|Console|0',
sender_id='TEST|0',
sender_name='',
target_from='TEST|Console',
sender_from='TEST', client_name='TEST', message_id=0,
reply_id=None),
session=AutoSession(message=c, target='TEST|Console|0', sender='TEST|0',
auto_interactions=None))
return MessageSession(target=MsgInfo(target_id='TEST|Console|0',
sender_id='TEST|0',
sender_name='',
target_from='TEST|Console',
sender_from='TEST', client_name='TEST', message_id=0,
reply_id=None),
session=Session(message=c, target='TEST|Console|0', sender='TEST|0'))

def as_display(self, text_only=False):
return self.session.message
Expand Down Expand Up @@ -169,5 +160,5 @@ async def post_message(module_name, message, user_list: List[FetchedSession] = N
await fetch.send_message(message)


Bot.MessageSession = Template
Bot.MessageSession = MessageSession
Bot.FetchTarget = FetchTarget
14 changes: 1 addition & 13 deletions core/types/message/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,6 @@ def __repr__(self):
return f'Session(message={self.message}, target={self.target}, sender={self.sender})'


class AutoSession(Session):
"""
For autotest
"""

def __init__(self, message, target, sender, auto_interactions=None):
super().__init__(message, target, sender)
if auto_interactions is None:
auto_interactions = []
self.auto_interactions = auto_interactions


class FinishedSession:
def __init__(self, session, message_id: Union[List[int], List[str], int, str], result):
self.session = session
Expand Down Expand Up @@ -342,5 +330,5 @@ def __init__(self, args: dict):
self.args = args


__all__ = ["FetchTarget", "MsgInfo", "MessageSession", "Session", "FetchedSession", "FinishedSession", "AutoSession",
__all__ = ["FetchTarget", "MsgInfo", "MessageSession", "Session", "FetchedSession", "FinishedSession",
"ModuleHookContext", "MessageChain"]

0 comments on commit 754a647

Please sign in to comment.