-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
executable file
·44 lines (35 loc) · 978 Bytes
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#! /usr/bin/python3
import random
from mastodon import Mastodon
dformats = [
"English: \'{}.\'\nEsperanto: \'{}\'",
"English: \'{}.\'\nEsperanto: \'{}\'",
"English: \'{}.\'\nEsperanto: \'{}\'",
"English: \'{}.\'\nEsperanto: \'{}\'",
"English: \'{}.\'\nEsperanto: \'{}\'",
"Instead of \'{}\', try saying \'{}\'",
"The Esperanto for \'{}\' is \'{}\'",
"The Esperanto for \'{}\' is \'{}\'",
"The Esperanto for \'{}\' is \'{}\'",
"{} = {}",
"{} = {}",
"Esperanto: \'{1}\'\nEnglish: \'{0}.\'"
]
with open("wl.txt", encoding="utf-8-sig") as f:
content = f.readlines()
wl = [x.strip() for x in content]
l = len(wl)
dl = len(dformats)
r = random.randint(0, l - 1)
dr = random.randint(0, dl - 1)
wpair = wl[r].split(" = ")
eng = wpair[0]
esp = wpair[1].capitalize()
fstr = dformats[dr]
tstr = fstr.format(eng, esp)
print(tstr)
mastodon = Mastodon(
access_token = "vortaro.secret",
api_base_url = "https://botsin.space"
)
mastodon.toot(tstr)