Fixed not saving locale config

This commit is contained in:
spla 2022-08-18 13:13:23 +02:00
pare 20fbdba2fe
commit cf10f4818d
S'han modificat 1 arxius amb 6 adicions i 20 eliminacions

Veure arxiu

@ -1,5 +1,5 @@
from mastodon import Mastodon from mastodon import Mastodon
from mastodon import MastodonMalformedEventError, MastodonNetworkError, MastodonReadTimeout, MastodonAPIError, MastodonIllegalArgumentError from mastodon.Mastodon import MastodonMalformedEventError, MastodonNetworkError, MastodonReadTimeout, MastodonAPIError, MastodonIllegalArgumentError
import getpass import getpass
import unidecode import unidecode
import fileinput,re import fileinput,re
@ -126,12 +126,7 @@ class Mastodonbot:
mastodon = Mastodon(client_id = "app_clientcred.txt", api_base_url = self.mastodon_hostname) mastodon = Mastodon(client_id = "app_clientcred.txt", api_base_url = self.mastodon_hostname)
grant_type = 'password' mastodon.log_in(
mastodon.__log_in(
client_id,
client_secret,
grant_type,
user_name, user_name,
user_password, user_password,
scopes = ["read", "write"], scopes = ["read", "write"],
@ -200,7 +195,6 @@ class Mastodonbot:
self.__create_config(self) self.__create_config(self)
self.__write_config(self) self.__write_config(self)
self.__read_config_line(self)
print("Secrets setup done!\n") print("Secrets setup done!\n")
@ -298,18 +292,10 @@ class Mastodonbot:
with open(self.config_filepath, 'a') as the_file: with open(self.config_filepath, 'a') as the_file:
the_file.write('mastodon_hostname: \n') the_file.write(f'mastodon_hostname: {self.mastodon_hostname}\n')
print(f"adding parameter 'mastodon_hostname' to {self.config_filepath}") the_file.write(f'bot_lang: {self.__bot_lang}\n')
print(f"adding parameter 'bot_lang' to {self.config_filepath}") print(f"adding parameter 'mastodon_hostname' to {self.config_filepath}\n")
print(f"adding parameter 'bot_lang' to {self.config_filepath}\n")
@staticmethod
def __read_config_line(self):
with open(self.config_filepath) as fp:
line = fp.readline()
self.__modify_file(self, self.config_filepath, "mastodon_hostname: ", value=self.mastodon_hostname)
self.__modify_file(self, self.config_filepath, "bot_lang: ", value=self.__bot_lang)
def get_data(self, notif): def get_data(self, notif):