mirror of
https://github.com/Xtao-Labs/misskey2telegram.git
synced 2024-11-25 22:59:19 +00:00
31 lines
934 B
Python
31 lines
934 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.text):
|
|
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.text):
|
|
await NoRepeatRenoteAction.push(uid, note.renote.id)
|