Example #1
0
async def handle_message_sent_history(bot: Bot, event: Event, state: T_State):
    try:
        user_name = event.dict().get('sender').get('card')
        if not user_name:
            user_name = event.dict().get('sender').get('nickname')
        time = event.dict().get('time')
        self_id = event.dict().get('self_id')
        post_type = event.get_type()
        detail_type = 'self_sent'
        sub_type = 'self'
        group_id = event.dict().get('group_id')
        user_id = event.dict().get('user_id')
        raw_data = repr(event)
        msg_data = str(event.dict().get('message'))
        new_event = DBHistory(time=time,
                              self_id=self_id,
                              post_type=post_type,
                              detail_type=detail_type)
        new_event.add(sub_type=sub_type,
                      group_id=group_id,
                      user_id=user_id,
                      user_name=user_name,
                      raw_data=raw_data,
                      msg_data=msg_data)
    except Exception as e:
        logger.error(f'Message history recording Failed, error: {repr(e)}')
Example #2
0
async def handle_notice(bot: Bot, event: Event, state: T_State):
    try:
        time = event.dict().get('time')
        self_id = event.dict().get('self_id')
        post_type = event.get_type()
        detail_type = event.dict().get(f'{event.get_type()}_type')
        sub_type = event.dict().get('sub_type')
        group_id = event.dict().get('group_id')
        user_id = event.dict().get('user_id')
        raw_data = repr(event)
        msg_data = str(event.dict().get('message'))
        new_event = DBHistory(time=time,
                              self_id=self_id,
                              post_type=post_type,
                              detail_type=detail_type)
        new_event.add(sub_type=sub_type,
                      group_id=group_id,
                      user_id=user_id,
                      user_name=None,
                      raw_data=raw_data,
                      msg_data=msg_data)
    except Exception as e:
        logger.error(f'Notice history recording Failed, error: {repr(e)}')