mirror of
https://github.com/Xtao-Labs/misskey2telegram.git
synced 2024-11-29 07:57:03 +00:00
31 lines
940 B
Python
31 lines
940 B
Python
from cashews import cache
|
|
from mipac import Note
|
|
|
|
|
|
class NoRepeatRenoteAction:
|
|
@staticmethod
|
|
async def push(uid: int, note_id: str) -> None:
|
|
await cache.set(f"pushed:{uid}:{note_id}", "true")
|
|
|
|
@staticmethod
|
|
async def get(uid: int, note_id: str) -> bool:
|
|
text = await cache.get(f"pushed:{uid}:{note_id}")
|
|
if text is None:
|
|
return False
|
|
return True
|
|
|
|
@staticmethod
|
|
async def check(uid: int, note: Note):
|
|
if await NoRepeatRenoteAction.get(uid, note.id):
|
|
return False
|
|
if note.renote and (not note.content):
|
|
if await NoRepeatRenoteAction.get(uid, note.renote.id):
|
|
return False
|
|
return True
|
|
|
|
@staticmethod
|
|
async def set(uid: int, note: Note):
|
|
await NoRepeatRenoteAction.push(uid, note.id)
|
|
if note.renote and (not note.content):
|
|
await NoRepeatRenoteAction.push(uid, note.renote.id)
|