mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-08 04:43:00 +08:00
add SimplePost
This commit is contained in:
parent
dca4c82cae
commit
48a5ed89e2
@ -306,6 +306,33 @@ class StatusChange(
|
|||||||
logger.warning("network connection error: {}, url: {}".format(type(err), err.request.url))
|
logger.warning("network connection error: {}, url: {}".format(type(err), err.request.url))
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
class SimplePost(
|
||||||
|
Platform,
|
||||||
|
MessageProcessMixin,
|
||||||
|
UserCustomFilterMixin,
|
||||||
|
StorageMixinProto,
|
||||||
|
abstract=True
|
||||||
|
):
|
||||||
|
"Fetch a list of messages, dispatch it to different users"
|
||||||
|
|
||||||
|
async def fetch_new_post(self, target: Target, users: list[UserSubInfo]) -> list[tuple[User, list[Post]]]:
|
||||||
|
try:
|
||||||
|
new_posts = await self.get_sub_list(target)
|
||||||
|
if not new_posts:
|
||||||
|
return []
|
||||||
|
else:
|
||||||
|
for post in new_posts:
|
||||||
|
logger.info('fetch new post from {} {}: {}'.format(
|
||||||
|
self.platform_name,
|
||||||
|
target if self.has_target else '-',
|
||||||
|
self.get_id(post)))
|
||||||
|
res = await self.dispatch_user_post(target, new_posts, users)
|
||||||
|
self.parse_cache = {}
|
||||||
|
return res
|
||||||
|
except httpx.RequestError as err:
|
||||||
|
logger.warning("network connection error: {}, url: {}".format(type(err), err.request.url))
|
||||||
|
return []
|
||||||
|
|
||||||
class NoTargetGroup(
|
class NoTargetGroup(
|
||||||
Platform,
|
Platform,
|
||||||
NoTargetMixin,
|
NoTargetMixin,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user