diff --git a/.env b/.env index 804629f..63f8fd8 100644 --- a/.env +++ b/.env @@ -1,7 +1,4 @@ API_BASE_URL= APP_SECRET_FILE=chesspuzzlebot-app.secret USER_SECRET_FILE=chesspuzzlebot-user.secret -# If empty, interactive prompt -MASTODON_USER_EMAIL= -MASTODON_PASSWORD= SQLITE_DB=db.sqlite diff --git a/README.md b/README.md index ed9ef7c..1408e86 100644 --- a/README.md +++ b/README.md @@ -76,8 +76,6 @@ The variables are:  - API_BASE_URL: URL to your Mastodon server. **NOTE! Every server instance has its own rules regarding bots. PLEASE read the rules before running the bot over there. - APP_SECRET_FILE and USER_SECRET_FILE: Path to the files where the API will store the app and user authentication. The files will be generated in the first run, and then you will not need to enter the credentials anymore. -- MASTODON_USER_EMAIL: Email registered in the server for the bot account. You must have a bot account in a Mastodon instance before running the bot. **Please refer to the [documentation](https://docs.joinmastodon.org/user/signup/) about signing up accounts and bot settings. -- MASTODON_PASSWORD: The password of the bot account. If you leave this variable empty, the password will be prompted interactively in the first run. - SQLITE_DB: Path to the SQLite file generated by the setup utility.  ## Starting up @@ -88,6 +86,8 @@ Once you have installed the dependencies, and generated the database, the tags.j  The program will set up the authentication (first run), and start listening the events notified by the server about user interactions.   +Since Mastodon 4.4, OAUTH password authentication is forbidden, so you have to copy the auth URL, log in a browser and copy the auth code. You only have to do this the first time, because the credentials will be stored in files. The old environment params MASTODON_USER_EMAIL and MASTODON_PASSWORD doesn't exist anymore. + The program is designed to run unattended without end. In case of connection is lost or any other errors, it will try to reconnect automatically.  There's an hourly routine that will post the "daily puzzle" and other challenges randomly to encourage followers to participate. diff --git a/chesspuzzlebot.py b/chesspuzzlebot.py index fe1e1e7..591c693 100644 --- a/chesspuzzlebot.py +++ b/chesspuzzlebot.py @@ -1,4 +1,3 @@ -import getpass import json import logging.config import os @@ -91,17 +90,13 @@ else: if not url: logger.error('API_BASE_URL not defined.') sys.exit(1) - # Create app and user credentials - user_email = os.getenv('MASTODON_USER_EMAIL', '') - pwd = os.getenv('MASTODON_PASSWORD', '') - if not user_email: - user_email = input('Username: ') - if not pwd: - pwd = getpass.getpass('Password: ') - logger.info(f"Usuario: {user_email} Pass: /{pwd}/") + # Create app and auth URL Mastodon.create_app('ChessPuzzleBot', api_base_url=url, to_file=app_file) mastodon = Mastodon(client_id=app_file) - mastodon.log_in(user_email, pwd, to_file=user_file) + print('Go to auth page and copy auth code:') + print(mastodon.auth_request_url()) + pwd = input("Input auth code: ") + mastodon.log_in(code=pwd, to_file=user_file)   def translate(language, string): diff --git a/requirements.txt b/requirements.txt index e6c8d20..1deaa8b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Mastodon.py~=1.8.1 +mastodon-py~=2.1.3 python-dotenv~=1.0.1 svglib~=1.5.1 rlPyCairo~=0.3.0