{ "info": { "author": "Jonathan Sick", "author_email": "jsick@lsst.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Programming Language :: Python :: 3.5" ], "description": "=================\ncommunity_mailbot\n=================\n\n.. image:: https://img.shields.io/pypi/v/community_mailbot.svg\n\nThe ``community_mailbot`` is a friendly bot that tells subscribers to LSST DM's legacy Mailman email lists about things happening on `community.lsst.org `_.\n\nThe bot likes to be awakened regularly by ``cron``; each time it will ask the Discourse server about latest messages in different categories that the bot tracks (you can set this with a simple ``config.json`` file).\nIf there is are new topics, ``community_mailbot`` will send an email to the appropriate email lists using its buddy, `Mandrill `_.\nBefore the bot goes back to sleep, it keeps note of all the topics it's emailed already in a simple JSON cache file.\n\nInstallation\n------------\n\nCreate a virtual environment running Python 3.5, then:\n\n.. code-block:: bash\n\n pip install community_mailbot\n\nRunning the community mailbot\n-----------------------------\n\nKeys to the Kingdom\n~~~~~~~~~~~~~~~~~~~\n\nYou'll need to get API keys from community.lsst.org and Mandrill.\nSet them to the following environment variables:\n\n* ``$MANDRILL_KEY`` (note, use the API key for the ``community_mailbot`` subaccount)\n* ``$DISCOURSE_KEY`` (the Discourse key should correspond to a user with sufficient permissions)\n* ``$DISCOURSE_USER``\n\nOptionally set ``$COMMUNITY_MAILBOT_CACHE`` to the location where you want the Mailbot to keep track of its topics it has forwarded.\n\nSetup Topic \u2192 Email Mapping\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nTo setup how Discourse categories are mapped to recipient email addresses, you need to know the integer IDs for each relevant category.\nTo get these, run the included script:\n\n.. code-block:: bash\n\n discourse_categories\n\nIf you set the aforementioned environment variables, you won't need to provide any arguments to the script.\n\nNext, create a ``config.json`` file.\nIt's a simple hash structure; each key-value pair is the Discourse category ID and a list of email recipients for that category.\nThe general format is:\n\n.. code-block:: json\n\n {\n \"\": [{\"email\": \"\",\n \"name\": \"\",\n \"type\": \"to\"}],\n }\n\nThe structure of the ``dict`` in the value matches the `Mandrill send-template API`_.\nThe ``\"type\"`` field should typically be ``\"to\"``, but could also be ``\"cc\"`` or ``\"bcc\"``.\n\n.. _`Mandrill send-template API`: https://mandrillapp.com/api/docs/messages.python.html#method-send-template\n\nNote that since the recipient information for each category is a ``list``, you can have multiple recipients.\n\nPre-cache old topics\n~~~~~~~~~~~~~~~~~~~~\n\nBefore having the bot send emails, you'll want it to know about and ignore older messages.\nTo warm up the cache, we'll run the ``forward_discourse`` script with the ``--cache-only`` option.\n\n.. code-block:: bash\n\n forward_discourse config.json --cache-only\n\nNote that ``forward_discourse`` can configure itself with the environment variables you've already setup.\nRun ``forward_discourse --help`` for the full set of options.\n\nSet up a cron schedule\n~~~~~~~~~~~~~~~~~~~~~~\n\nThe bot works best when it regularly monitors a Discourse site for new topics.\n``cron`` is a great way to set this up.\n\nIt's useful to create a shell script to contain all of the script arguments.\nFor example, create a script called ``run_mailbot.sh``:\n\n.. code-block:: bash\n\n #!/bin/bash\n source /home/ec2-user/.bash_profile\n source activate community_mailbot\n forward_discourse /home/ec2-user/config.json\n\n echo \"$(date) Ran forward_discourse\"\n\nThis script sets up up the shell environment, loads a Python environment, and then runs the mailbot.\n\nThen instruct ``cron`` to run this script every 10 minutes\n\nFirst, open the ``crontab`` in your terminal\n\n.. code-block:: bash\n\n crontab -e\n\nAnd add a line for the bot\n\n.. code-block:: bash\n\n */10 * * * * /home/ec2-user/run_mailbot.sh\n\nThen sit back and watch the email flow.\n\nDevelopment\n-----------\n\nTo develop on the ``community_mailbot``, you'll need to clone the repository and install a development copy (preferably in a ``virtualenv``):\n\n.. code-block:: bash\n\n git clone https://github.com/lsst-sqre/community_mailbot.git\n cd community_mailbot\n python setup.py develop\n\nTo run the test suite:\n\n.. code-block:: bash\n\n python -m unittest discover -s community_mailbot/tests\n\n\nRough Spots\n-----------\n\nThe ``community_mailbot`` is meant to be fairly general and usable for any Discourse installation.\n\n*However*, beware that the Mandrill email template information is current hard-coded.\nIdeally this would be user-configurable.\n\n\nLicense\n-------\n\nCopyright 2015 AURA/LSST.\n\nMIT licensed; see ``LICENSE`` file.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/lsst-sqre/community_mailbot", "keywords": "astronomy discourse email", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "community_mailbot", "package_url": "https://pypi.org/project/community_mailbot/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/community_mailbot/", "project_urls": { "Homepage": "https://github.com/lsst-sqre/community_mailbot" }, "release_url": "https://pypi.org/project/community_mailbot/0.1.1/", "requires_dist": [ "beautifulsoup4", "mandrill", "requests" ], "requires_python": "", "summary": "Friendly mail forwarding bot for community.lsst.org", "version": "0.1.1" }, "last_serial": 1760956, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "2258987c3a93af7f4147847106dbf976", "sha256": "23dbec6def84be3d9c37cc74a752d89c3b77fe3841a17985fc81176abc9628c1" }, "downloads": -1, "filename": "community_mailbot-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "2258987c3a93af7f4147847106dbf976", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13580, "upload_time": "2015-10-10T04:19:55", "url": "https://files.pythonhosted.org/packages/b9/29/f75dc858e8c75fe566fd197fe4ff38308042667b8c7da348a5ca69f0c709/community_mailbot-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9933509d811c19e8d9a6fcf7c7555728", "sha256": "f8c0592b2effd19d2fe93e24ad1eb8ec2d6fbc9c47bbfa005bb2b87779322e37" }, "downloads": -1, "filename": "community_mailbot-0.1.0.tar.gz", "has_sig": false, "md5_digest": "9933509d811c19e8d9a6fcf7c7555728", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8817, "upload_time": "2015-10-10T04:19:58", "url": "https://files.pythonhosted.org/packages/58/a8/618f3e8baba46e602d0d078882a28764050d12d4168b7c8f011adf9cbd5b/community_mailbot-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "e091f6a170ad32fd2f7696eb5bf7fada", "sha256": "e4de99bbc997752c28c0893bbbf86ab6c771d7eebb3af08ff872760eba535984" }, "downloads": -1, "filename": "community_mailbot-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "e091f6a170ad32fd2f7696eb5bf7fada", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13591, "upload_time": "2015-10-10T04:27:53", "url": "https://files.pythonhosted.org/packages/55/5d/6eaba3c58160ef35b367922e4ac48002d18f52951f9356b3bfd4c7de5e7e/community_mailbot-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6973fd2f6fe6b4219fea617f1da0f386", "sha256": "394e70e6dd876c665387e8ccde4327083b50bdb7c6a53543b6e2acdf2321c532" }, "downloads": -1, "filename": "community_mailbot-0.1.1.tar.gz", "has_sig": false, "md5_digest": "6973fd2f6fe6b4219fea617f1da0f386", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8839, "upload_time": "2015-10-10T04:27:57", "url": "https://files.pythonhosted.org/packages/e8/44/1021d410043fa77f735b5d74eafaac6661d05356909b5c286e41cfd4dd7a/community_mailbot-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e091f6a170ad32fd2f7696eb5bf7fada", "sha256": "e4de99bbc997752c28c0893bbbf86ab6c771d7eebb3af08ff872760eba535984" }, "downloads": -1, "filename": "community_mailbot-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "e091f6a170ad32fd2f7696eb5bf7fada", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13591, "upload_time": "2015-10-10T04:27:53", "url": "https://files.pythonhosted.org/packages/55/5d/6eaba3c58160ef35b367922e4ac48002d18f52951f9356b3bfd4c7de5e7e/community_mailbot-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6973fd2f6fe6b4219fea617f1da0f386", "sha256": "394e70e6dd876c665387e8ccde4327083b50bdb7c6a53543b6e2acdf2321c532" }, "downloads": -1, "filename": "community_mailbot-0.1.1.tar.gz", "has_sig": false, "md5_digest": "6973fd2f6fe6b4219fea617f1da0f386", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8839, "upload_time": "2015-10-10T04:27:57", "url": "https://files.pythonhosted.org/packages/e8/44/1021d410043fa77f735b5d74eafaac6661d05356909b5c286e41cfd4dd7a/community_mailbot-0.1.1.tar.gz" } ] }