Browse Source

Initial commit

merge-requests/1/head
Carl Chenet 4 years ago
commit
058773e9ab
25 changed files with 1419 additions and 0 deletions
  1. +8
    -0
      .gitignore
  2. +2
    -0
      AUTHORS
  3. +21
    -0
      CHANGELOG
  4. +39
    -0
      LICENSE
  5. +68
    -0
      README.md
  6. +177
    -0
      docs/Makefile
  7. +4
    -0
      docs/source/authors.rst
  8. +261
    -0
      docs/source/conf.py
  9. +135
    -0
      docs/source/configure.rst
  10. +27
    -0
      docs/source/index.rst
  11. +36
    -0
      docs/source/install.rst
  12. +4
    -0
      docs/source/license.rst
  13. +38
    -0
      docs/source/plugins.rst
  14. +56
    -0
      docs/source/use.rst
  15. +36
    -0
      remindr.py
  16. +15
    -0
      remindr/__init__.py
  17. +97
    -0
      remindr/cfgparse.py
  18. +75
    -0
      remindr/cliparse.py
  19. +31
    -0
      remindr/formatnextmessage.py
  20. +54
    -0
      remindr/getlastblogentry.py
  21. +69
    -0
      remindr/main.py
  22. +28
    -0
      remindr/tootpost.py
  23. +25
    -0
      scripts/feed2toot
  24. +64
    -0
      scripts/register_remindr_app
  25. +49
    -0
      setup.py

+ 8
- 0
.gitignore View File

@ -0,0 +1,8 @@
docs/build/
__pycache__
*.swp
*.pyc
*.db
*.ini
*.txt
*.bck

+ 2
- 0
AUTHORS View File

@ -0,0 +1,2 @@
Antoine Beaupré <anarcat@debian.org>
Carl Chenet <chaica@ohmytux.com>

+ 21
- 0
CHANGELOG View File

@ -0,0 +1,21 @@
## [0.5] - 2017-05-05
### Added
- manage rss feeds entries without id
## [0.4] - 2017-04-28
### Changed
- [hashtaglist] section is not mandatory any more
- bugfixes
## [0.3] - 2017-04-12
### Changed
- remove persistentlist dependency because unstable and use own cache storage
## [0.2] - 2017-04-11
### Changed
- register_feed2toot_app now able to generate credentials for any instance
- remove useless tweepy dependencies
## [0.1] - 2017-04-09
### Changed
- forking from feed2tweet

+ 39
- 0
LICENSE View File

@ -0,0 +1,39 @@
Copyright © 2017, Carl Chenet
Copyright © 2017 Carl Chenet <carl.chenet@ohmytux.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
The original code was under:
MIT License
Copyright (c) 2012, Todd Eddy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

+ 68
- 0
README.md View File

@ -0,0 +1,68 @@
### Remindr
Remindr automatically parses rss feeds, stores rss entries and posts reminders of the last ones to social networks, like the [Mastodon](https://joinmastodon.org) or ([Twitter](https://twitter.com).
For the full documentation, [read it online](https://remindr.readthedocs.org/en/latest/).
If you would like, you can [support the development of this project on Liberapay](https://liberapay.com/carlchenet/).
Alternatively you can donate cryptocurrencies:
- BTC: 1MaFaUbmJcTVN9wsm5bzqFyq6zWu434X3A
- XMR: 43GGv8KzVhxehv832FWPTF7FSVuWjuBarFd17QP163uxMaFyoqwmDf1aiRtS5jWgCiRsi73yqedNJJ6V1La2joznKHGAhDi
### Quick Install
* Install Remindr from PyPI
# pip3 install remindr
* Install Remindr from sources
*(see the installation guide for full details)
[Installation Guide](http://remindr.readthedocs.org/en/latest/install.html)*
# tar zxvf remindr-0.1.tar.gz
# cd remindr
# python3 setup.py install
# # or
# python3 setup.py install --install-scripts=/usr/bin
### Create the authorization for the Remindr app
* Just launch the following command::
$ register_remindr_app
### Use Remindr
* Create or modify remindr.ini file in order to configure remindr:
[mastodon]
instance_url=https://mastodon.social
user_credentials=remindr_usercred.txt
client_credentials=remindr_clientcred.txt
; Default visibility is public, but you can override it:
; toot_visibility=unlisted
[database]
database=remindr.db
[rss]
uri=https://carlchenetcom/feed/
[message]
message={title} {link}
[hashtaglist]
several_words_hashtags_list=hashtags.txt
* Launch Remindr
$ remindr -c /path/to/remindr.ini
### Authors
* Carl Chenet <chaica@ohmytux.com>
### License
This software comes under the terms of the GPLv3+.

+ 177
- 0
docs/Makefile View File

@ -0,0 +1,177 @@
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = build
# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
endif
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/backupchecker.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/backupchecker.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/backupchecker"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/backupchecker"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
latexpdfja:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."

+ 4
- 0
docs/source/authors.rst View File

@ -0,0 +1,4 @@
Authors
=======
Carl Chenet <chaica@ohmytux.com>

+ 261
- 0
docs/source/conf.py View File

@ -0,0 +1,261 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# feed2toot documentation build configuration file, created by
# sphinx-quickstart on Wed Dec 17 18:25:26 2014.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.1'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = 'feed2toot'
copyright = '2017, Carl Chenet <chaica@ohmytux.com>'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '1.0'
# The full version, including alpha/beta/rc tags.
release = '1.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = []
# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
#html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'feed2tootdoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'feed2toot.tex', 'feed2toot Documentation',
'Carl Chenet \\textless{}chaica@ohmytux.com.org\\textgreater{}', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'feed2toot', 'feed2toot Documentation',
['Carl Chenet <chaica@ohmytux.com>'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'feed2toot', 'feed2toot Documentation',
'Carl Chenet <chaica@ohmytux.com>', 'feed2toot', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False

+ 135
- 0
docs/source/configure.rst View File

@ -0,0 +1,135 @@
Configure Feed2toot
===================
As a prerequisite to use Feed2toot, you need to authorize a Mastodon app for your account.
Just use the script register_feed2toot_app to register the feed2toot app for your account.::
$ ./register_feed2toot_app
This app generates Mastodon app credentials needed by Feed2toot.
feed2toot_clientcred.txt and feed2toot_usercred.txt will be written in the current dir /home/chaica/progra/python/feed2toot.
One connection is initiated to create the app.
Your password is *not* stored.
Mastodon instance url (defaults to https://mastodon.social):
Mastodon login:chaica@ohmytux.com
Mastodon password:
The feed2toot app was added to your preferences=>authorized apps page
As described above, two files were created. You'll need them in the feed2toot configuration.
In order to configure Feed2toot, you need to create a feed2toot.ini file (or any name you prefer, finishing with the extension .ini) with the following parameters::
[mastodon]
instance_url=https://mastodon.social
; Here you need the two files created by register_feed2toot_app
user_credentials=/etc/feed2toot/credentials/feed2toot_usercred.txt
client_credentials=/etc/feed2toot/credentials/feed2toot_clientcred.txt
; Default visibility is public, but you can override it:
; toot_visibility=unlisted
[cache]
cachefile=/var/lib/feed2toot/feed2toot.db
cache_limit=10000
[rss]
uri=https://www.journalduhacker.net/rss
uri_list=/etc/feed2toot//rsslist.txt
tweet={title} {link}
title_pattern=Open Source
title_pattern_case_sensitive=true
no_uri_pattern_no_global_pattern=true
[hashtaglist]
several_words_hashtags_list=/etc/feed2toot/hashtags.txt
For the [mastodon] section:
- instance_url: the url of your Mastodon instance
- user_credentials: a file with the user credentials, generated by the command register_feed2toot_app
- client_credentials: a file with the client credentials, generated by the command register_feed2toot_app
- toot_visibility: any of the valid options for the *visibility* field
`here`__.
Default is *public*, but *unlisted* prevents flooding
the instance's public timeline (which is more polite).
__ https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md#posting-a-new-status
For the [cache] section:
- cachefile: the path to the cache file storing ids of already tweeted links. Absolute path is mandatory. This file should always use the .db extension.
- cache_limit: length of the cache queue. defaults to 100.
For the [rss] section:
- uri: the url of the rss feed to parse
- uri_list: a path to a file with several adresses of rss feeds, one by line. Absolute path is mandatory.
- tweet: format of the tweet you want to post. It should use existing entries of the RSS fields like {title} or {link}. Launch it with this field empty to display all available entries.
- {one field of the rss feed}_pattern: takes a string representing a pattern to match for a specified field of each rss entry of the rss feed, like title_pattern or summary_pattern.
- {one field of the rss feed}_pattern_case_sensitive: either the pattern matching for the specified field should be case sensitive or not. Default to true if not specified.
- no_uri_pattern_no_global_pattern: don't apply global pattern (see above) when no pattern-by-uri is defined in the uri_list. Allows to get all entries of a rss in the uri_list because no pattern is defined so we match them all. Defaults to false, meaning the global patterns will be tried on every rss in the uri_list NOT HAVING specific patterns and so ONLY entries from the specific uri in the uri_list matching the global patterns will be considered.
For the [hashtaglist] section:
- several_words_hashtags_list: a path to the file containing hashtags in two or more words. Absolute path is mandatory. By default Feed2toot adds a # before every words of a hashtag. See documentation below for an example of this file.
Example of the list of hash tags
================================
The list of hash tags is a simple text file with one hash tag composed by several words on a single line::
free software community
open-source
Instead of having #free #software #community or #open-source in the resulting toot, you will have #freesoftwarecommunity and #opensource. You only have to identify the hash tags you frequently use in your RSS feeds and put them in this file to have well formatted hash tags in your toots.
List of rss feeds
=================
Simple list of rss feeds
------------------------
With the parameter **uri_list**, you can define a list of uri to use. Feed2toot is able to match specific patterns for each of the rss feeds from this list. Consider the following rss section of the configuration file::
[rss]
uri_list=/home/john/feed2toot/rsslist.txt
tweet={title} {link}
Now let's have a look at the =/home/john/feed2toot/rsslist.txt file::
https://www.journalduhacker.net/rss
https://carlchenet.com/feed
Each line of this file is a url to a rss feed. Pretty simple.
Match specific patterns of rss feeds in the uri_list files
----------------------------------------------------------
You can use specific pattern matching for uri in the uri_list file to filter some of the rss entries of a rss feed. Lets modify the previous file::
https://www.journalduhacker.net/rss|title|hacker,psql
https://carlchenet.com/feed|title|gitlab
Each line of this file starts with an uri, followed by a pipe (|), followed by the name of the available section to parse (see below), again followed by a pipe (|), followed by patterns, each pattern being separated from the other one by a semi-colon (,).
In the example file above wee get every rss entries from the feed available at https://www.journalduhacker.net/rss where a substring in the title section of this entry matches either "hacker" or "psql". Specific patterns are not case sensitive. For the second line, we match every rss entries from the feed available at https://carlchenet.com/feed where a substring in the title section of this entry matches "gitlab".
Consider every entries of a rss feed from a uri in the uri_list file
--------------------------------------------------------------------
It is possible to get all entries from a rss feed available in the uri_list file. You need an option to deactivate the global pattern matching for uri in the uri_list NOT having specific patterns::
[rss]
...
no_uri_pattern_no_global_pattern=true
In you rsslist.txt, just don't give anything else than the needed feed url to get all the entries::
https://www.journalduhacker.net/rss|title|hacker,psql
https://carlchenet.com/feed|title|gitlab
https://blog.linuxjobs.fr/feed.php?rss
The last line of the file above only has the url of a rss feed. All entries from this feed will be tweeted.
How to display available sections of the rss feed
=================================================
Feed2toot offers the **--rss-sections** command line option to display the available section of the rss feed and exits::
$ feed2toot --rss-sections -c feed2toot.ini
The following sections are available in this RSS feed: ['title', 'comments', 'authors', 'link', 'author', 'summary', 'links', 'tags', id', 'author_detail', 'published'].

+ 27
- 0
docs/source/index.rst View File

@ -0,0 +1,27 @@
Documentation for the Feed2toot project
=======================================
Feed2toot parses a RSS feed, extracts the last entries and sends them to Mastodon.
You'll find below anything you need to install, configure or run Feed2toot.
Guide
=====
.. toctree::
:maxdepth: 2
install
configure
use
plugins
license
authors
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

+ 36
- 0
docs/source/install.rst View File

@ -0,0 +1,36 @@
How to install Feed2toot
========================
From PyPI
^^^^^^^^^
$ pip3 install feed2toot
From sources
^^^^^^^^^^^^
* You need at least Python 3.4.
* On some Linux Distribution **setuptools** package does not come with default python install, you need to install it.
* Install **PIP**::
$ wget https://bootstrap.pypa.io/get-pip.py -O - | sudo python3
* Install **setuptools** module::
$ wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python3
Alternatively, Setuptools may be installed to a user-local path::
$ wget https://bootstrap.pypa.io/ez_setup.py -O - | python3 - --user
* Untar the tarball and go to the source directory with the following commands::
$ tar zxvf feed2toot-0.5.tar.gz
$ cd feed2toot
* Next, to install Feed2toot on your computer, type the following command with the root user::
$ python3 setup.py install
$ # or
$ python3 setup.py install --install-scripts=/usr/bin

+ 4
- 0
docs/source/license.rst View File

@ -0,0 +1,4 @@
License
=======
This software comes under the terms of the **GPLv3+**. It was previously under the **MIT** license. See the LICENSE file for the complete history of the license and the full text of the past and current licenses.

+ 38
- 0
docs/source/plugins.rst View File

@ -0,0 +1,38 @@
Plugins
=======
Feed2toot supports plugins. Plugins offer optional features, not supported by default. Optional means you need a dedicated configuration and sometimes a dedicated external dependencies. What you need for each module is specified below.
InfluxDB
--------
The InfluxDB plugin allows to store already published tweets in a InfluxDB database.
Install the InfluxDB plugin
^^^^^^^^^^^^^^^^^^^^^^^^^^^
To install Feed2toot with the InfluxDB plugin, execute the following command.
From scratch::
# pip3 install feed2toot[influxdb]
Upgrading from a previous version, execute the followin command::
# pip3 install feed2toot[influxdb] --upgrade
Configuration
^^^^^^^^^^^^^
Below is the block of configuration to add in your feed2toot.ini::
[influxdb]
;host=127.0.0.1
;port=8086
user=influxuser
pass=V3ryS3cr3t
database=influxdb
measurement=tweets
- host: the host where the influxdb instance is. Defaults to 127.0.0.1
- port: the port where the influxdb instance is listening to. Defaults to 8086
- user: the user authorized to connect to the database. Mandatory (no default)
- pass: the password needed to connect to the database. Mandatory (no default)
- database: the name of the influxdb database to connect to. Mandatory (no default)
- measurement: the measurement to store the value into. Mandatory (no default)

+ 56
- 0
docs/source/use.rst View File

@ -0,0 +1,56 @@
Use Feed2toot
==============
After the configuration of Feed2toot, just launch the following command::
$ feed2toot -c /path/to/feed2toot.ini
Run Feed2toot on a regular basis
=================================
Feed2toot should be launche on a regular basis in order to efficiently send your new RSS entries to Mastodon. It is quite easy to achieve with adding a line to your user crontab, as described below::
@hourly feed2toot -c /path/to/feed2toot.ini
will execute feed2toot every hour. Or without the syntactic sugar in the global crontab file /etc/crontab::
0 * * * * johndoe feed2toot -c /path/to/feed2toot.ini
Test option
===========
In order to know what's going to be sent to Mastodon without actually doing it, use the **--dry-run** option::
$ feed2toot --dry-run -c /path/to/feed2toot.ini
Debug option
============
In order to increase the verbosity of what's Feed2toot is doing, use the **--debug** option followed by the level of verbosity see [the the available different levels](https://docs.python.org/3/library/logging.html)::
$ feed2toot --debug -c /path/to/feed2toot.ini
Populate the cache file without posting tweets
==============================================
Starting from 0.8, Feed2toot offers the **--populate-cache** command line option to populate the cache file without posting to Mastodon::
$ feed2toot --populate-cache -c feed2toot.ini
populating RSS entry https://www.journalduhacker.net/s/65krkk
populating RSS entry https://www.journalduhacker.net/s/co2es0
populating RSS entry https://www.journalduhacker.net/s/la2ihl
populating RSS entry https://www.journalduhacker.net/s/stfwtx
populating RSS entry https://www.journalduhacker.net/s/qq1wte
populating RSS entry https://www.journalduhacker.net/s/y8mzrp
populating RSS entry https://www.journalduhacker.net/s/ozjqv0
populating RSS entry https://www.journalduhacker.net/s/6ev8jz
populating RSS entry https://www.journalduhacker.net/s/gezvnv
populating RSS entry https://www.journalduhacker.net/s/lqswmz
How to display available sections of the rss feed
=================================================
Starting from 0.8, Feed2toot offers the **--rss-sections** command line option to display the available section of the rss feed and exits::
$ feed2toot --rss-sections -c feed2toot.ini
The following sections are available in this RSS feed: ['title', 'comments', 'authors', 'link', 'author', 'summary', 'links', 'tags', id', 'author_detail', 'published'].
Using syslog
============
Feed2toot is able to send its log to syslog. You can use it with the following command::
$ feed2toot --syslog=WARN -c /path/to/feed2toot.ini

+ 36
- 0
remindr.py View File

@ -0,0 +1,36 @@
#!/usr/bin/env python3
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2015-2017 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
# Launch Remindr
'''Launch Remindr'''
import sys
from remindr.main import Main
class Remindr:
'''Remindr class'''
def __init__(self):
'''Constructor of the Feed2Toot class'''
self.main()
def main(self):
'''Main of the Remindr class'''
Main()
if __name__ == '__main__':
Main()
sys.exit(0)

+ 15
- 0
remindr/__init__.py View File

@ -0,0 +1,15 @@
#!/usr/bin/env python3
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2017 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>

+ 97
- 0
remindr/cfgparse.py View File

@ -0,0 +1,97 @@
# -*- coding: utf-8 -*-
# Copyright © 2015-2017 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/
# Get values of the configuration file
'''Get values of the configuration file'''
# standard library imports
from configparser import SafeConfigParser, NoOptionError, NoSectionError
import logging
import os
import os.path
import socket
import sys
# 3rd party library imports
import feedparser
def cfgparse(clioptions):
'''Parse the configurations'''
for pathtoconfig in clioptions.configs:
options = {}
# read the configuration file
config = SafeConfigParser()
if not config.read(os.path.expanduser(pathtoconfig)):
sys.exit('Could not read the configuration file')
###########################
#
# the mastodon section
#
###########################
section = 'mastodon'
if config.has_section(section):
############################
# instance_url option
############################
confoption = 'instance_url'
if config.has_option(section, confoption):
options[confoption] = config.get(section, confoption)
else:
sys.exit('You should define Mastodon instance url with the "{confoption}" in the [{section}] section'.format(confoption=confoption, section=section))
############################
# user_credentials option
############################
confoption = 'user_credentials'
if config.has_option(section, confoption):
options[confoption] = config.get(section, confoption)
else:
sys.exit('You should define Mastodon user credentials for with "{confoption}" in the [{section}] section'.format(confoption=confoption, section=section))
if config.has_section(section):
############################
# client_credentials
############################
confoption = 'client_credentials'
if config.has_option(section, confoption):
options[confoption] = config.get(section, confoption)
else:
sys.exit('You should define Mastodon client credentials with the "{confoption}" in the [{section}] section'.format(confoption=confoption, section=section))
############################
# toot_visibility
############################
confoption = 'toot_visibility'
if config.has_option(section, confoption):
options[confoption] = config.get(section, confoption, fallback='public')
###########################
#
# the entrylist section
#
###########################
section = 'entrylist'
if config.has_section(section):
confoption = 'path_to_list'
options['path_to_list'] = config.get(section, confoption)
else:
sys.exit('You should provide a {confoption} parameter in the [{section}] section'.format(section=section, confoption=confoption))
###########################
#
# the prefix section
#
###########################
section = 'prefix'
if config.has_section(section):
for prefixoption in config[section]:
if prefixoption.endswith('_prefix'):
options[prefixoption] = config.get(section, prefixoption)
return options

+ 75
- 0
remindr/cliparse.py View File

@ -0,0 +1,75 @@
# -*- coding: utf-8 -*-
# Copyright © 2017 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
# CLI parsing
'''CLI parsing'''
# standard library imports
from argparse import ArgumentParser
import glob
import logging
import os.path
import sys
__version__ = '0.5'
def cliparse():
'''Parse the command line to get options'''
epilog = 'For more information: https://remindr.readhthedocs.org'
description = 'Send toots to remind people about blog entries'
parser = ArgumentParser(prog='remindr',
description=description,
epilog=epilog)
parser.add_argument('--version', action='version', version=__version__)
parser.add_argument('-c', '--config',
default=[os.path.join(os.getenv('XDG_CONFIG_HOME', '~/.config'),
'remindr.ini')],
nargs='+',
dest="config",
help='Location of config file (default: %(default)s)',
metavar='FILE')
parser.add_argument('-n', '--dry-run', dest='dryrun',
action='store_true', default=False,
help='Do not actually post toots')
parser.add_argument('-v', '--verbose', '--info', dest='log_level',
action='store_const', const='info', default='warning',
help='enable informative (verbose) output, work on log level INFO')
parser.add_argument('-d', '--debug', dest='log_level',
action='store_const', const='debug', default='warning',
help='enable debug output, work on log level DEBUG')
levels = [i for i in logging._nameToLevel.keys()
if (type(i) == str and i != 'NOTSET')]
parser.add_argument('--syslog', nargs='?', default=None,
type=str.upper, action='store',
const='INFO', choices=levels,
help='''log to syslog facility, default: no
logging, INFO if --syslog is specified without
argument''')
opts = parser.parse_args()
# verify if the path to cache file is an absolute path
# get the different config files, from a directory or from a *.ini style
opts.config = list(map(os.path.expanduser, opts.config))
for element in opts.config:
if element and not os.path.exists(element):
sys.exit('You should provide an existing path for the config file: %s' % element)
if os.path.isdir(element):
opts.configs = glob.glob(os.path.join(element, '*.ini'))
else:
# trying to glob the path
opts.configs = glob.glob(element)
# verify if a configuration file is provided
if not opts.configs:
sys.exit('no configuration file was found at the specified path(s) with the option -c')
return opts

+ 31
- 0
remindr/formatnextmessage.py View File

@ -0,0 +1,31 @@
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2017 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
'''Manage entries to remind to users'''
# standard libraires imports
import os
import os.path
import sys
def formatnextmessage(options, content):
'''Format the next message'''
nextmessage = ''
language = content[0:2]
for parameter in options:
if parameter.endswith('_prefix'):
if parameter.startswith(language):
nextmessage = ' '.join([options[parameter], content[3:]])
return nextmessage

+ 54
- 0
remindr/getlastblogentry.py View File

@ -0,0 +1,54 @@
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2017 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
'''Manage entries to remind to users'''
# standard libraires imports
import os
import os.path
import sys
def getlastblogentry(options):
'''Return the last blog entry'''
lastblogentry = ''
newlist = []
nextmessage = False
pathtolist = options['path_to_list']
# read the list of blog entries
with open(pathtolist) as lstc:
listofentries = lstc.readlines()
for line in listofentries:
elements = line.split()
if len(elements) < 3:
sys.exit('The list of messages does not seem valid. Please format it correcty before retrying')
else:
# extract the current line from the file of the list of blog entries
status = elements[0]
# detect if the line should be used
if status == 'o' and not nextmessage:
nextmessage = True
lastblogentry = line[2:]
newlist.append(''.join(['x', line[1:]]))
# configure the next line to be usded
elif status == 'x' and nextmessage:
newlist.append(''.join(['o', line[1:]]))
nextmessage = False
else:
newlist.append(line)
# rewrite the modified file
with open(pathtolist, 'w') as lstc:
lstc.writelines(newlist)
return lastblogentry

+ 69
- 0
remindr/main.py View File

@ -0,0 +1,69 @@
#!/usr/bin/env python3
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2017 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
'''Checks an RSS feed, format it, store it and posts new entries to the social networks.'''
# standard libraires imports
import codecs
import importlib
import logging
import logging.handlers
import os
import sys
# 3rd party libraries imports
import feedparser
# app libraries imports
from remindr.addtags import AddTags
from remindr.cliparse import cliparse
from remindr.cfgparse import cfgparse
from remindr.formatnextmessage import formatnextmessage
from remindr.getlastblogentry import getlastblogentry
from remindr.tootpost import tootpost
class Main(object):
'''Main class of Feed2toot'''
def __init__(self):
self.main()
def setup_logging(self, options):
if options.syslog:
sl = logging.handlers.SysLogHandler(address='/dev/log')
sl.setFormatter(logging.Formatter('remindr[%(process)d]: %(message)s'))
# convert syslog argument to a numeric value
loglevel = getattr(logging, options.syslog.upper(), None)
if not isinstance(loglevel, int):
raise ValueError('Invalid log level: %s' % loglevel)
sl.setLevel(loglevel)
logging.getLogger('').addHandler(sl)
logging.debug('configured syslog level %s' % loglevel)
logging.getLogger('').setLevel(logging.DEBUG)
sh = logging.StreamHandler()
sh.setLevel(options.log_level.upper())
logging.getLogger('').addHandler(sh)
logging.debug('configured stdout level %s' % sh.level)
def main(self):
'''The main function'''
clioptions = cliparse()
self.setup_logging(clioptions)
# iterating over the different configuration files
cfgvalues = cfgparse(clioptions)
nextcontent = getlastblogentry(cfgvalues)
nextmessage = formatnextmessage(cfgvalues, nextcontent)
tootpost(cfgvalues, nextmessage)

+ 28
- 0
remindr/tootpost.py View File

@ -0,0 +1,28 @@
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2017 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
'''Post a reminder through a toot'''
# 3rd party libraries imports
from mastodon import Mastodon
def tootpost(options, toot):
'''post a reminder through a toot'''
mastodon = Mastodon(
client_id=options['client_credentials'],
access_token=options['user_credentials'],
api_base_url=options['instance_url']
)
mastodon.status_post(toot, visibility=options['toot_visibility'])

+ 25
- 0
scripts/feed2toot View File

@ -0,0 +1,25 @@
#!/usr/bin/env python3
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2015-2017 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
# Feed2toot startup
'''Feed2toot startup'''
import sys
from feed2toot.main import Main
if __name__ == '__main__':
Main()
sys.exit(0)

+ 64
- 0
scripts/register_remindr_app View File

@ -0,0 +1,64 @@
#!/usr/bin/env python3
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2017 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
from getpass import getpass
from os import getcwd
from mastodon import Mastodon
from mastodon.Mastodon import MastodonIllegalArgumentError
import sys
print('\nThis script generates the Mastodon application credentials for Remindr.\nremindr_clientcred.txt and remindr_usercred.txt will be written\nin the current directory: {cwd}.\nA connection is initiated to create the application.\nYour password is *not* stored.\n'.format(cwd=getcwd()))
# get the instance
instance = input('Mastodon instance URL (defaults to https://mastodon.social): ')
if not instance:
instance = 'https://mastodon.social'
elif not instance.startswith('http'):
instance = ''.join(['https://', instance])
# get the username
userok = False
while not userok:
user = input('Mastodon login: ')
if not user:
print('Your Mastodon username can not be empty.')
userok = False
elif '@' not in user or '.' not in user:
print('Your Mastodon username should be an email.')
userok = False
else:
userok = True
# get the password
password = getpass(prompt='Mastodon password: ')
Mastodon.create_app(
'remindr',
api_base_url=instance,
to_file = '{cwd}/remindr_clientcred.txt'.format(cwd=getcwd())
)
mastodon = Mastodon(client_id = '{cwd}/remindr_clientcred.txt'.format(cwd=getcwd()),
api_base_url=instance)
try:
mastodon.log_in(
user,
password,
to_file = '{cwd}/remindr_usercred.txt'.format(cwd=getcwd())
)
except MastodonIllegalArgumentError as err:
print(err)
sys.exit('\nI guess you entered a bad login or password.\n')
print('remindr was added to your preferences=>authorized apps page.')
sys.exit(0)

+ 49
- 0
setup.py View File

@ -0,0 +1,49 @@
# Copyright 2017 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
#!/usr/bin/env python3
# Setup for Remindr
'''Setup for Remindr'''
from setuptools import setup, find_packages
CLASSIFIERS = [
'Intended Audience :: End Users/Desktop',
'Environment :: Console',
'License :: OSI Approved :: GNU General Public License (GPL)',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6'
]
setup(
name='remindr',
version='0.1',
license='GNU GPL v3',
description='Automatically send toots/tweets to remind people about the last blog entries on social networks',
long_description='Automatically get data from a influx database and send toots/tweets to remind people about the last blog entries on social networks',
author = 'Carl Chenet',
author_email = 'chaica@ohmytux.com',
url = 'https://gitlab.com/chaica/remindr',
classifiers=CLASSIFIERS,
download_url='https://gitlab.com/chaica/remindr',
packages=find_packages(),
scripts=['scripts/remindr', 'scripts/register_remindr_app'],
install_requires=['feedparser', 'Mastodon.py'],
extras_require={
'twitter': 'tweepy']
}
)

Loading…
Cancel
Save