mirror of
https://gitea.phreedom.club/localhost_frssoft/FMN_bot.git
synced 2025-07-27 03:54:16 +00:00
FMN picture uploading
This commit is contained in:
parent
6033095e89
commit
099285c147
4 changed files with 23 additions and 9 deletions
|
@ -35,7 +35,7 @@ def get_status(status_id):
|
|||
return r.json()
|
||||
|
||||
|
||||
def post_status(text, reply_to_status_id=None, poll_options=None, poll_expires=345600):
|
||||
def post_status(text, reply_to_status_id=None, poll_options=None, poll_expires=345600, attachments=None):
|
||||
poll = None
|
||||
if poll_options is not None:
|
||||
poll = {
|
||||
|
@ -43,14 +43,28 @@ def post_status(text, reply_to_status_id=None, poll_options=None, poll_expires=3
|
|||
"expires_in": poll_expires,
|
||||
"multiple": True
|
||||
}
|
||||
print(poll_options)
|
||||
params = {
|
||||
"status": text,
|
||||
"in_reply_to_id": reply_to_status_id,
|
||||
"visibility": "unlisted",
|
||||
"content_type": "text/plain",
|
||||
"language": "ru",
|
||||
"poll": poll
|
||||
}
|
||||
if attachments:
|
||||
params['media_ids'] = attachments
|
||||
r = requests.post(instance_point + "/statuses", json=params, headers=headers)
|
||||
return r.json()
|
||||
|
||||
|
||||
def upload_attachment(file_path):
|
||||
file = {
|
||||
"file": open(file_path, mode='rb')
|
||||
}
|
||||
params = {
|
||||
"description": "Fediverse Movie Night\nВоскресенье, 21:00\nLIVE ON XXIV Production",
|
||||
}
|
||||
r = requests.post(instance_point + "/media", params, files=file, headers=headers)
|
||||
return r.json()['id']
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue