nova Class Post

This commit is contained in:
spla 2023-01-27 13:16:10 +01:00
pare 663125fdf8
commit 4edc1c31be

Veure arxiu

@ -1,6 +1,7 @@
from setup import Setup from setup import Setup
from xatapi import Xat from xatapi import Xat
from mastodon import Mastodon from mastodon import Mastodon
from post import Post
import re import re
import time import time
import sys import sys
@ -143,67 +144,23 @@ if __name__ == '__main__':
else: else:
post = Post()
answer = xat.completions(prompt=prompt) answer = xat.completions(prompt=prompt)
answer = answer.choices[0]['text'] answer = answer.choices[0]['text']
if 'com.example.demo.controller' not in answer: if 'com.example.demo.controller' not in answer:
post_text = f'@{username} {answer}' post_array = post.split(answer, username)
if len(post_text) > 500: for postit in post_array:
len_post1 = 500 - len(username) - 4 post_id = mastodon.status_post(postit, in_reply_to_id=status_id,visibility=visibility).id
post_text1 = post_text[:len_post1] + '... ' status_id = post_id
post_text2 = f'@{username} ...{post_text[len_post1:]}' time.sleep(2)
if len(post_text2) > 500:
len_post2 = 500 - len(username) - 8
post_text2 = f'{post_text2[:len_post2]}...'
post_text3 = f'@{username} ...{post_text2[len_post2:]}'
try:
post_id = mastodon.status_post(post_text1, in_reply_to_id=status_id,visibility=visibility).id
post_id = mastodon.status_post(post_text2, in_reply_to_id=post_id,visibility=visibility).id
mastodon.status_post(post_text3, in_reply_to_id=post_id,visibility=visibility)
except:
print(f'Notification {notification_id} dissmised')
mastodon.notifications_dismiss(notification_id)
pass
else:
post_id = mastodon.status_post(post_text1, in_reply_to_id=status_id,visibility=visibility).id
mastodon.status_post(post_text2, in_reply_to_id=post_id,visibility=visibility)
else:
try:
mastodon.status_post(post_text, in_reply_to_id=status_id,visibility=visibility)
except:
print(f'Notification {notification_id} dissmised')
mastodon.notifications_dismiss(notification_id)
pass
time.sleep(5)
print(f'Notification {notification_id} replied') print(f'Notification {notification_id} replied')