newline issue solved
This commit is contained in:
parent
20d8872b99
commit
5bcb7a6278
3 changed files with 8 additions and 5 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
.env
|
||||
.vscode/
|
||||
txt/*
|
|
@ -5,7 +5,7 @@ CLIENT_ID = ''
|
|||
CLIENT_SECRET = ''
|
||||
ACCESS_TOKEN = ''
|
||||
|
||||
# File with messages (one per line) to be tooted. Must be in txt directory.
|
||||
# File with messages (one per line) to be tooted. Must be in 'txt' directory.
|
||||
ANNOUNCEMENT_FILE = 'es. announce.txt'
|
||||
|
||||
# Set to 1 to enable random read from ANNOUNCEMENT_FILE
|
||||
|
|
|
@ -34,20 +34,20 @@ def megafono():
|
|||
|
||||
if int(RANDOM):
|
||||
import random
|
||||
toot = random.choice(list(open(ANNOUNCEMENT_FILE, "r")))
|
||||
toot = random.choice(list(open(ANNOUNCEMENT_FILE, 'r')))
|
||||
else:
|
||||
last_id = 0
|
||||
with open(last_id_file) as f:
|
||||
last_id = int(f.read())
|
||||
with open(ANNOUNCEMENT_FILE, "r") as a:
|
||||
with open(ANNOUNCEMENT_FILE, 'r', encoding='utf8') as a:
|
||||
toot = a.readlines()[last_id]
|
||||
with open(ANNOUNCEMENT_FILE, "r") as a:
|
||||
with open(ANNOUNCEMENT_FILE, 'r') as a:
|
||||
length = len(a.readlines())
|
||||
last_id += 1
|
||||
last_id %= length
|
||||
with open(last_id_file, 'w+') as f:
|
||||
f.write(str(last_id))
|
||||
mastodon.status_post(toot, visibility='unlisted')
|
||||
mastodon.status_post(toot.replace('\\n','\n'), visibility='unlisted')
|
||||
print("Sent: "+str(toot))
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue