No respon si es mencionen dos o més usuaris. Ja dona respostes de tres o més tuts

This commit is contained in:
spla 2023-01-28 21:19:15 +01:00
pare 4edc1c31be
commit e815476da4
S'han modificat 3 arxius amb 47 adicions i 8 eliminacions

Veure arxiu

@ -83,6 +83,8 @@ if __name__ == '__main__':
for notif in notifications: for notif in notifications:
post_array = []
notification_id = notif.id notification_id = notif.id
if notif.type != 'mention': if notif.type != 'mention':
@ -107,6 +109,20 @@ if __name__ == '__main__':
if reply == True: if reply == True:
content = cleanhtml(text)
search_char = '@'
counter = len([element for element in content.split() if search_char in element])
if counter > 1:
print(f'Notification {notification_id} dissmised')
mastodon.notifications_dismiss(notification_id)
continue
prompt = unescape(query_word) prompt = unescape(query_word)
if prompt[:7] == 'imatge:': if prompt[:7] == 'imatge:':
@ -126,6 +142,8 @@ if __name__ == '__main__':
mastodon.status_post(post_text, in_reply_to_id=status_id, media_ids={image_id}, visibility=visibility) mastodon.status_post(post_text, in_reply_to_id=status_id, media_ids={image_id}, visibility=visibility)
mastodon.notifications_dismiss(notification_id)
else: else:
post_text = f'@{username} {prompt[8:]}' post_text = f'@{username} {prompt[8:]}'
@ -134,6 +152,8 @@ if __name__ == '__main__':
mastodon.status_post(post_text, in_reply_to_id=status_id, visibility=visibility) mastodon.status_post(post_text, in_reply_to_id=status_id, visibility=visibility)
mastodon.notifications_dismiss(notification_id)
except: except:
pass pass
@ -142,6 +162,10 @@ if __name__ == '__main__':
mastodon.status_post(post_text, in_reply_to_id=status_id, visibility=visibility) mastodon.status_post(post_text, in_reply_to_id=status_id, visibility=visibility)
print(f'Notification {notification_id} replied')
mastodon.notifications_dismiss(notification_id)
else: else:
post = Post() post = Post()
@ -154,17 +178,28 @@ if __name__ == '__main__':
post_array = post.split(answer, username) post_array = post.split(answer, username)
for postit in post_array: i = 0
while i < len(post_array):
post_id = mastodon.status_post(postit, in_reply_to_id=status_id,visibility=visibility).id print(f'array element: {i} of {len(post_array)}, username: {username}, status_id: {status_id}, post: {post_array[i]}')
post_id = mastodon.status_post(post_array[i], in_reply_to_id=status_id, visibility=visibility).id
status_id = post_id status_id = post_id
time.sleep(2) i += 1
print(f'Notification {notification_id} replied') print(f'Notification {notification_id} replied')
mastodon.notifications_dismiss(notification_id) mastodon.notifications_dismiss(notification_id)
if isinstance(post, Post):
post.clear()
time.sleep(1)
continue
else: else:

Veure arxiu

@ -11,6 +11,10 @@ class Post:
self.n = n self.n = n
self.array = array self.array = array
def clear(self):
self.array.clear()
def split(self, post, username): def split(self, post, username):
self.post = post self.post = post
@ -22,7 +26,7 @@ class Post:
self.n = post_len / 500 self.n = post_len / 500
start = 0 start = 0
end = 494 end = 488
i = 0 i = 0
while i < self.n: while i < self.n:
@ -32,7 +36,7 @@ class Post:
self.array.append(post) self.array.append(post)
start = end-len(self.username) start = end-len(self.username)
end = end + 494 end = end + 488
i += 1 i += 1

Veure arxiu

@ -50,7 +50,7 @@ class Xat:
data = { data = {
'model': "text-davinci-003", 'model': "text-davinci-003",
'prompt': prompt, 'prompt': prompt,
'max_tokens': 500, 'max_tokens': 750,
'temperature': 0 'temperature': 0
} }