Fix #2 (nova Class Post)

This commit is contained in:
spla 2023-01-27 13:10:33 +01:00
pare 0b56f14aab
commit 663125fdf8

40
post.py Normal file
Veure arxiu

@ -0,0 +1,40 @@
import pdb
class Post:
name = 'Mastodon post splitter'
def __init__(self, post=None, username=None, n=None, array=[]):
self.post = post
self.username = username
self.n = n
self.array = array
def split(self, post, username):
self.post = post
self.username = username
post_len = len(self.post)
self.n = post_len / 500
start = 0
end = 494
i = 0
while i < self.n:
post = f'@{self.username} {self.post[start:end-len(self.username)]}'
self.array.append(post)
start = end-len(self.username)
end = end + 494
i += 1
return self.array