mirror of
https://github.com/cquest/tootbot.git
synced 2025-02-23 10:58:25 +00:00
replace print() with log() to stderr in cyan color
This commit is contained in:
parent
16212f800a
commit
e58dc043cf
11
tootbot.py
11
tootbot.py
@ -14,6 +14,9 @@ import feedparser
|
|||||||
from mastodon import Mastodon
|
from mastodon import Mastodon
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
def log(msg):
|
||||||
|
if False:
|
||||||
|
print('\033[96m'+msg+'\033[0m', file=sys.stderr) # cyan in console
|
||||||
|
|
||||||
def unredir(redir):
|
def unredir(redir):
|
||||||
r = requests.get(redir, allow_redirects=False)
|
r = requests.get(redir, allow_redirects=False)
|
||||||
@ -94,20 +97,22 @@ if not os.path.isfile(instance+'.secret'):
|
|||||||
api_base_url='https://'+instance,
|
api_base_url='https://'+instance,
|
||||||
to_file=instance+'.secret'
|
to_file=instance+'.secret'
|
||||||
):
|
):
|
||||||
print('tootbot app created on instance '+instance)
|
log('tootbot app created on instance '+instance)
|
||||||
else:
|
else:
|
||||||
print('failed to create app on instance '+instance)
|
log('failed to create app on instance '+instance)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
global mastodon_api
|
||||||
try:
|
try:
|
||||||
mastodon_api = Mastodon(access_token=mastodon+".secret")
|
mastodon_api = Mastodon(access_token=mastodon+".secret")
|
||||||
|
log('logged')
|
||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
mastodon_api = Mastodon(
|
mastodon_api = Mastodon(
|
||||||
client_id=instance+'.secret',
|
client_id=instance+'.secret',
|
||||||
api_base_url='https://'+instance
|
api_base_url='https://'+instance
|
||||||
)
|
)
|
||||||
print('login')
|
log('login')
|
||||||
mastodon_api.log_in(
|
mastodon_api.log_in(
|
||||||
username=mastodon,
|
username=mastodon,
|
||||||
password=passwd,
|
password=passwd,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user