mirror of
https://git.phreedom.club/localhost_frssoft/FMN_bot.git
synced 2024-11-24 20:20:56 +01:00
fedi_api will be still attempt get response
This commit is contained in:
parent
a949ecd9b6
commit
27b51fcd3f
|
@ -18,8 +18,18 @@ def get_notifications():
|
|||
"limit": 15,
|
||||
"types": ["mention"]
|
||||
}
|
||||
success = 0
|
||||
while success == 0:
|
||||
try:
|
||||
r = requests.get(instance_point + "/notifications", json=params, headers=headers)
|
||||
r.raise_for_status()
|
||||
success = 1
|
||||
return r.json()
|
||||
except:
|
||||
logger.exception('Error get notificatios')
|
||||
time.sleep(30)
|
||||
logger.info('Retrying get notificatios...')
|
||||
|
||||
|
||||
|
||||
def mark_as_read_notification(id_notification):
|
||||
|
@ -33,7 +43,7 @@ def mark_as_read_notification(id_notification):
|
|||
except:
|
||||
logger.exception(f'Error read notification {id_notification}')
|
||||
time.sleep(30)
|
||||
logger.info('Retrying read notification {id_notification}...')
|
||||
logger.info(f'Retrying read notification {id_notification}...')
|
||||
|
||||
|
||||
def get_status_context(status_id):
|
||||
|
@ -51,8 +61,18 @@ def get_status_context(status_id):
|
|||
|
||||
|
||||
def get_status(status_id):
|
||||
success = 0
|
||||
while success == 0:
|
||||
try:
|
||||
r = requests.get(instance_point + f"/statuses/{status_id}", headers=headers)
|
||||
r.raise_for_status()
|
||||
success = 1
|
||||
return r.json()
|
||||
except:
|
||||
logger.exception(f'Error get status {status_id}')
|
||||
time.sleep(30)
|
||||
logger.info(f'Retrying get status {status_id}')
|
||||
|
||||
|
||||
|
||||
def post_status(text, reply_to_status_id=None, poll_options=None, poll_expires=345600, attachments=None):
|
||||
|
@ -92,8 +112,19 @@ def upload_attachment(file_path):
|
|||
params = {
|
||||
"description": "Fediverse Movie Night\nВоскресенье, 21:00\nLIVE ON XXIV Production",
|
||||
}
|
||||
success = 0
|
||||
while success == 0:
|
||||
try:
|
||||
r = requests.post(instance_point + "/media", params, files=file, headers=headers)
|
||||
r.raise_for_status()
|
||||
success = 1
|
||||
return r.json()['id']
|
||||
except:
|
||||
logger.exception(f'Error uploading {file_path} attachment')
|
||||
time.sleep(5)
|
||||
logger.info(f'Retrying upload {file_path}...')
|
||||
|
||||
|
||||
|
||||
|
||||
def mute_user(acct_id=str, acct=str, duration=None):
|
||||
|
|
Loading…
Reference in New Issue
Block a user