From e66f870e80425e4e22bfb825a60f4d4783e567d3 Mon Sep 17 00:00:00 2001
From: m33m33 <m33@tok715.net>
Date: Mon, 17 Aug 2020 14:50:10 +0200
Subject: [PATCH] Added token authentication method

---
 README.md                       | 21 ++++++++++++++++-----
 tootbot@my_bot@my_instance.conf | 20 ++++++++++++++++++++
 2 files changed, 36 insertions(+), 5 deletions(-)
 create mode 100644 tootbot@my_bot@my_instance.conf

diff --git a/README.md b/README.md
index c0124dd..68cde79 100644
--- a/README.md
+++ b/README.md
@@ -3,9 +3,7 @@
 A small python 3.x script to replicate tweets on a mastodon account.
 
 Forked from https://github.com/cquest/tootbot
-Specialized in rss feed in particular from Nitter https://github.com/zedeus/nitter
-
-The script only need mastodon login/pass to post toots.
+Specialized in RSS feed, in particular from Nitter (https://nitter.net - https://github.com/zedeus/nitter)
 
 It gets the tweets from RSS available at https://nitter.net, then does some cleanup on the content:
 - twitter tracking links (t.co) are dereferenced
@@ -16,7 +14,7 @@ It can also toot RSS/atom feeds (see cron-example.sh).
 
 A sqlite database is used to keep track of tweets than have been tooted.
 
-The script is simply called by a cron job and can run on any server (does not have to be on the mastodon instance server).
+The script is simply called by a cron job and can run on any server.
 
 ## Setup
 
@@ -29,10 +27,23 @@ cd tootbot
 pip3 install -r requirements.txt
 ```
 
+## Configuration file
+
+The configuration file should be placed in a safe directory (not world or group readable), and contains the instance and authentication credentials. 
+You must complete the config file and provide authentication credentials to your desired mastodon account. 
+A sample config file 'tootbot@my_bot@my_instance.conf' is provided as a starting point.
+
+## Authentication methods
+
+This app support both email and application token authentication.
+You are strongly encouraged to create an application with dedicated app id, secret and access token for this bot.
+See the "Development" and "New application" pannel in your mastodon account settings.
+
 ## Useage
 
 With a plain RSS/atom feed:
 
-`python3 tootbot.py https://your-rssfeed-source.com/recent.atom @your_mastodon_username_account@botsin.space **password** botsin.space 2 #your_hashtag 0 your_mastondon_email_account`
+`python3 tootbot.py [full path to authentication config file] https://your-rssfeed-source.com/recent.atom 2 your_hashtag 0`
 
 (all arguments are mandatory)
+
diff --git a/tootbot@my_bot@my_instance.conf b/tootbot@my_bot@my_instance.conf
new file mode 100644
index 0000000..18b3021
--- /dev/null
+++ b/tootbot@my_bot@my_instance.conf
@@ -0,0 +1,20 @@
+# tootbot config file
+
+# the bot mastodon account name (something like @mytoobot)
+mastodon_account=@
+
+# The mastodon instance server (without https://)#
+instance: something like mastodon.social
+
+# auth_type: token or email
+# The prefered way is to create an app in the masdoton account, and create a dedicated id,secret,token trio for this bot
+auth_type: token
+
+# If you use a token auth_type, fill and uncomment this lines:
+#app_client_id: generated on the mastodon account development pannel + new app
+#app_client_secret: generated on the mastodon account development pannel + new app
+#app_access_token: generated on the mastodon account development pannel + new app
+
+# If you use an email auth_type, fill and uncomment this lines:
+#mastodon_email_account: the mastodon user email
+#mastodon_email_password: the mastoon user passwd
-- 
GitLab