Revert "will now update profile pic based upon spacestate if configured"
This reverts commit a352f3e442
.
The profile image is cached too aggressively for this scheme to work
This commit is contained in:
parent
c9820bee96
commit
11c94f47cf
3 changed files with 5 additions and 27 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,2 @@
|
|||
config.py
|
||||
__pycache__/
|
||||
./open.png
|
||||
./closed.png
|
|
@ -9,10 +9,6 @@ spacestate_profile_key = 'Spacestate'
|
|||
open_profile_field = 'Open! @ {}'
|
||||
closed_profile_field = 'Closed @ {}'
|
||||
|
||||
update_profilepic_on_spacestate_change = True
|
||||
spacestate_open_profilepic = './open.png'
|
||||
spacestate_closed_profilepic = './closed.png'
|
||||
|
||||
profile_fields = [('Website', 'https://bitlair.nl/')]
|
||||
access_token = 'aaaaAAAAaaaa1234'
|
||||
homeserver = 'https://hsnl.social'
|
|
@ -5,16 +5,10 @@ import config
|
|||
import datetime
|
||||
from mastodon import Mastodon
|
||||
|
||||
if hasattr(config, 'update_profilepic_on_spacestate_change'):
|
||||
update_profilepic_on_spacestate_change = config.update_profilepic_on_spacestate_change
|
||||
else:
|
||||
# backcompat, standaard false
|
||||
update_profilepic_on_spacestate_change = False
|
||||
|
||||
def set_profile_fields(profile_open_text_value, picture = None):
|
||||
def set_profile_fields(profile_open_text_value):
|
||||
profile_fields = config.profile_fields
|
||||
profile_fields.append((config.spacestate_profile_key, profile_open_text_value))
|
||||
mastodon.account_update_credentials(fields=profile_fields, avatar=picture)
|
||||
mastodon.account_update_credentials(fields=profile_fields)
|
||||
# don't be alarmed by the method name, this is just for updating profile metadata
|
||||
print(profile_fields)
|
||||
|
||||
|
@ -26,21 +20,11 @@ def on_connect(client, userdata, flags, rc):
|
|||
|
||||
def on_message(client, userdata, msg):
|
||||
message = msg.payload.decode("UTF-8")
|
||||
print(message)
|
||||
cur_dt_string = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
new_avatar = None
|
||||
new_profile_value = None
|
||||
if message == config.open_string:
|
||||
if update_profilepic_on_spacestate_change:
|
||||
new_avatar = config.spacestate_open_profilepic
|
||||
new_profile_value = config.open_profile_field.format(cur_dt_string)
|
||||
set_profile_fields(config.open_profile_field.format(cur_dt_string))
|
||||
elif message == config.closed_string:
|
||||
if update_profilepic_on_spacestate_change:
|
||||
new_avatar = config.spacestate_open_profilepic
|
||||
new_profile_value = config.closed_profile_field.format(cur_dt_string)
|
||||
|
||||
if new_profile_value is not None:
|
||||
set_profile_fields(new_profile_value, picture=new_avatar)
|
||||
set_profile_fields(config.closed_profile_field.format(cur_dt_string))
|
||||
|
||||
mastodon = Mastodon(access_token=config.access_token, api_base_url=config.homeserver)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue