mirror of
https://gitea.phreedom.club/localhost_frssoft/FMN_bot.git
synced 2024-11-25 23:41:30 +00: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,
|
"limit": 15,
|
||||||
"types": ["mention"]
|
"types": ["mention"]
|
||||||
}
|
}
|
||||||
r = requests.get(instance_point + "/notifications", json=params, headers=headers)
|
success = 0
|
||||||
return r.json()
|
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):
|
def mark_as_read_notification(id_notification):
|
||||||
|
@ -33,7 +43,7 @@ def mark_as_read_notification(id_notification):
|
||||||
except:
|
except:
|
||||||
logger.exception(f'Error read notification {id_notification}')
|
logger.exception(f'Error read notification {id_notification}')
|
||||||
time.sleep(30)
|
time.sleep(30)
|
||||||
logger.info('Retrying read notification {id_notification}...')
|
logger.info(f'Retrying read notification {id_notification}...')
|
||||||
|
|
||||||
|
|
||||||
def get_status_context(status_id):
|
def get_status_context(status_id):
|
||||||
|
@ -51,8 +61,18 @@ def get_status_context(status_id):
|
||||||
|
|
||||||
|
|
||||||
def get_status(status_id):
|
def get_status(status_id):
|
||||||
r = requests.get(instance_point + f"/statuses/{status_id}", headers=headers)
|
success = 0
|
||||||
return r.json()
|
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):
|
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 = {
|
params = {
|
||||||
"description": "Fediverse Movie Night\nВоскресенье, 21:00\nLIVE ON XXIV Production",
|
"description": "Fediverse Movie Night\nВоскресенье, 21:00\nLIVE ON XXIV Production",
|
||||||
}
|
}
|
||||||
r = requests.post(instance_point + "/media", params, files=file, headers=headers)
|
success = 0
|
||||||
return r.json()['id']
|
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):
|
def mute_user(acct_id=str, acct=str, duration=None):
|
||||||
|
|
Loading…
Reference in a new issue