summaryrefslogtreecommitdiff
path: root/generate.py
blob: fd4803d48560ff9b480a620bd52a3a20241fe00e (plain)
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
import chain
import sys
import requests

import secrets__
import config__

model_f = open(config__.model_file)
model = chain.Text.from_json(model_f.read())

generated = False
text = None

while not generated:
    text = model.make_short_sentence(config__.character_limit, tries=900, min_words=3)
    generated = text is not None

text = text.replace('@','@​').replace('#','#​')
print(text)

apicreate = "https://" + config__.instance_url + "/api/notes/create"\

if(config__.cw == ""):
    requests.post(apicreate, json={
        'i': secrets__.TOKEN,

        'visibility': 'home',
        'noExtractMentions': True,
        'noExtractHashtags': True,

        'text': text,
    })
else:
    requests.post(apicreate, json={
        'i': secrets__.TOKEN,

        'visibility': 'home',
        'noExtractMentions': True,
        'noExtractHashtags': True,

        'text': text,
        'cw': config__.cw
    })