{ "info": { "author": "Gwildor Sok", "author_email": "gwildorsok@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "Intended Audience :: Information Technology", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.0", "Programming Language :: Python :: 3.1", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Communications", "Topic :: Communications :: Chat", "Topic :: Communications :: Chat :: Internet Relay Chat", "Topic :: Internet", "Topic :: Software Development", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Application Frameworks" ], "description": "|Build Status| |Latest Version| |Coverage Status| |MIT License|\n\nSimple framework for creating IRC bots.\n\nExample\n~~~~~~~\n\ninit.py:\n\n.. code:: python\n\n from pyromancer.objects import Pyromancer\n\n p = Pyromancer('test.settings')\n p.run()\n\ntest/settings.py:\n\n.. code:: python\n\n host = '1.2.3.4'\n port = 6667\n nick = 'PyromancerBot'\n encoding = 'ISO-8859-1'\n\nCustom commands\n~~~~~~~~~~~~~~~\n\nWriting own commands is fairly simple. Create a folder which will be the\npackage name, with a file named ``commands.py`` in it to hold the\ncommands. In ``commands.py``, you can register functions to be a command\nwith the built-in command decorator.\n\nExample\n^^^^^^^\n\nFile layout:\n\n::\n\n test/\n __init__.py\n commands.py\n settings.py\n init.py\n\ncommands.py:\n\n.. code:: python\n\n from pyromancer.decorators import command\n\n\n @command(r'bye (.*)')\n def bye(match):\n return 'Bye {m[1]}!'\n\nOn IRC:\n\n::\n\n bye everyone\n Bye everyone!\n\nPyromancer scans automatically for functions decorated using the\ncommands decorator, so all your commands in ``commands.py`` are used\nautomatically.\n\nYou can also create a directory named ``commands`` with submodules\ncontaining the commands. Just make sure that you import either the\nmodules or all of the commands in the ``__init__.py`` file.\n\nThe ``command`` decorator\n^^^^^^^^^^^^^^^^^^^^^^^^^\n\nYou must apply this to a function to mark it as a command. It will be\nused when scanning for and collecting commands.\n\nParameters\n''''''''''\n\n- ``patterns`` - a regular expression or a list of expressions. When a\n list is given, all patterns are attempted when matching the input,\n and only when all patterns in the list fail to match, the command is\n not executed.\n\n .. code:: python\n\n @command(['hi', 'hello'])\n def hi(match):\n return 'Hello!'\n\n- ``prefix`` - a boolean which defaults to ``True``. When true, the\n command pattern is only attempted to match when the message line\n starts with the prefix defined in the settings of the bot. This is\n useful for commands which are very bot-like (in contrary to commands\n which look and behave like natural language). Using a boolean and a\n setting allows the same command to be triggered in different ways,\n depending on the settings of the bot which installed the command\n package.\n\n- ``raw`` - a boolean which defaults to ``False``. When true, the raw\n input line sent from the server is used for matching the pattern,\n instead of the message. Useful for matching lines which are not a\n message from an user, such as nick or topic changes.\n\nMessaging from a command\n^^^^^^^^^^^^^^^^^^^^^^^^\n\nMessaging from inside the function which makes up the command is as easy\nas can be for simple use cases, but can be done in numerous ways for the\nmore complex situations.\n\nMost of the times, arguments are passed to the ``Match.msg`` function,\nwhich applies formatting by default and provides some additional\nutilities. The most important of those is that when no target has been\npassed on as an argument, it will use either the channel or the user (in\ncase of a PM) whose input line triggered the command to be executed as\nthe target, effectively replying.\n\nParameters\n''''''''''\n\n- ``message`` - the message to be send to the server. Formatting will\n be applied using any additional ``args`` and ``kwargs``, so you can\n apply the full power of the `Python Format\n Mini-Language `__\n on the message.\n\n- ``args`` and ``kwargs`` - arguments to be passed on through the\n formatting which is applied on ``message``.\n\nMethods of messaging\n''''''''''''''''''''\n\n- Return a ``message``\n\n .. code:: python\n\n @command(r'bye (.*)')\n def bye(match):\n return 'Bye {m[1]}!'\n\n- Return a tuple of ``message`` and optional ``args`` and ``kwargs`` to\n be used when formatting ``message``. ``args`` can be both a list of\n arguments, or simply all the middle elements of the tuple.\n\n .. code:: python\n\n def gibberish(match):\n return 'A = {}, B = {}, C = {c_char}', 'a', 'b', {'c_char': 'c'}\n\n- Yield a ``message`` or a tuple of ``message`` and optional ``args``\n and ``kwargs``. Yielding can be done as much as you want, which is\n the easiest way of sending multiple messages from one command.\n\n .. code:: python\n\n @command(r'say (.*)')\n def say(match):\n for part in match[1].split(', '):\n yield 'Saying {}', part\n\n- Return a list of ``message`` or a tuple of ``message`` and optional\n ``args`` and ``kwargs``.\n\n .. code:: python\n\n def hi(match):\n return ['Hi', 'Hello']\n\n- Use ``Match.msg``. This is the only way to benefit from the\n non-default functionalities provided by this function.\n\n .. code:: python\n\n def raw(match):\n match.msg('Raw {} message {m[1]}', raw=True)\n\nExtra parameters for ``Match.msg``\n''''''''''''''''''''''''''''''''''\n\n- ``target`` - the target to send the message to. If not provided, it\n will attempt to use either the channel or user whose input line\n triggered the command, which effectively results in replying.\n\n- ``raw`` - defaults to ``False``. When true, no formatting is applied\n on ``message``.\n\nTimers\n~~~~~~\n\nYou can register timers in a custom ``timers`` module, or you can create\nthem from inside commands or other timers. When creating or registering\na timer, you can either specify a ``timedelta`` or ``datetime`` object\nto schedule the timer. When specifying a timedelta, you can also specify\nthe amount of times the timer should execute, which defaults to\ninfinite. Timers can send messages based on arguments given upon\ninitialization, but also call a callable which in itself can send\nmessages or initialize new timers.\n\nWhen messaging from a timer, you must always specify a target to send\nthe message to before the message (when returning a message tuple), or\nwith the ``target`` argument on the ``Match`` instance when using the\n``Match.msg`` method. Because there is no line which triggered the\ntimer, nothing can be used to decide where to send the message to when\nthe target is not specified.\n\nExample of timers through a module\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\ntimers.py:\n\n.. code:: python\n\n from datetime import datetime, timedelta\n\n from pyromancer.decorators import timer\n\n\n @timer(timedelta(seconds=3), count=5)\n def say_time(match):\n return 'User', \"It's {}\", datetime.now()\n\nExample of timers through messaging\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\ncommands.py:\n\n.. code:: python\n\n from datetime import datetime, timedelta\n\n from pyromancer.decorators import timer\n\n\n @command(r'start_timer')\n def start_timer(match):\n return timedelta(seconds=3), 'User', \"It's {}\", datetime.now()\n\nYou can also return a ``Timer`` instance, or specify a callable as the\nsecond item of the returned tuple, which is then called like any\nfunction with the ``timer`` decorator.\n\nUsing a database\n~~~~~~~~~~~~~~~~\n\nUsing a database requires `SQLAlchemy `__.\n\nTo enable the integrated database support, you have to set the\n``database`` setting to a string which holds the URL to the database, as\naccepted by `SQLAlchemy's\ncreate\\_engine `__\nfunction. Then, in a ``models`` module, you can import the `declarative\nbase `__\nto construct your model, and import the\n`Session `__ for\nquerying.\n\nExample with a simple model and timer\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nThis example creates a table named ``test`` in a SQLite ``test.db``\nfile, and creates an entry with the current date and time every three\nseconds, and a command which returns the count of entries in the table.\n\nsettings.py:\n\n.. code:: python\n\n database = 'sqlite:///test.db'\n\nmodels.py:\n\n.. code:: python\n\n from sqlalchemy import Column, DateTime, Integer\n\n from pyromancer.database import Base\n\n\n class Test(Base):\n __tablename__ = 'test'\n\n id = Column(Integer, primary_key=True)\n value = Column(DateTime)\n\ntimers.py:\n\n.. code:: python\n\n from datetime import datetime, timedelta\n\n from pyromancer.database import Session\n from pyromancer.decorators import timer\n\n from .models import Test\n\n\n @timer(timedelta(seconds=3))\n def hi(match):\n session = Session()\n session.add(Test(value=datetime.now()))\n session.commit()\n\ncommands.py:\n\n.. code:: python\n\n from pyromancer.database import Session\n from pyromancer.decorators import command\n\n from .models import Test\n\n\n @command(r'timers')\n def timers(match):\n session = Session()\n return 'Timer count: {}', session.query(Test).count()\n\nSupport\n~~~~~~~\n\nPython 2.7 and 3.0 - 3.4 are supported. Note that development occurs on\nPython 3.\n\nTo do\n~~~~~\n\n- Figure out how to do translation of messages through the\n ``Match.msg`` function.\n\nChangelist\n~~~~~~~~~~\n\n1.0 - 2014-10-18\n^^^^^^^^^^^^^^^^\n\n- Add timers.\n- Add integrated database support.\n- Add command module which tracks channels and users.\n- Change color code parameter in message formatting to ``c`` (was ``k``\n by mistake).\n- Dropped [irc][1] as a dependency.\n- Switch to MIT license. [1]: https://pypi.python.org/pypi/irc\n\n0.4 - 2014-03-30\n^^^^^^^^^^^^^^^^\n\n- Add support for Python 2.7.\n- Add more tests.\n- Fix messaging with positional arguments given as a list not working.\n- Add ability to create commands for raw code lines by specifying a\n code to match.\n- Add ability to do easy message formatting for colored, underlined and\n bold text.\n\n0.3 - 2014-03-22\n^^^^^^^^^^^^^^^^\n\n- Change settings to be a Python module instead of a dictionary.\n- Change package loading.\n- Enable the commands from the package of which the settings are in by\n default.\n- Add ability to process raw input lines.\n- Add option to use precompiled regular expressions in the command\n decorator.\n- Add option to pass flags for compiling the regular expressions in the\n command decorator.\n- Fix returning message from command not working.\n\n0.2 - 2014-03-14\n^^^^^^^^^^^^^^^^\n\n- Add tests.\n- Add multiple and easier ways to send messages from a command.\n- Add support for multiple patterns for the same command.\n- Add a configurable command prefix setting for the more bot-like\n commands.\n- Trying to access a word in a ``Line`` now correctly returns an empty\n string when the index does not exist.\n- Fix passing positional arguments to ``Match.msg`` not working\n properly.\n\n0.1 - 2013-11-17\n^^^^^^^^^^^^^^^^\n\n- Initial release.\n\n.. |Build Status| image:: http://img.shields.io/travis/Gwildor/Pyromancer.svg\n :target: https://travis-ci.org/Gwildor/Pyromancer\n.. |Latest Version| image:: http://img.shields.io/pypi/v/Pyromancer.svg\n :target: https://pypi.python.org/pypi/Pyromancer\n.. |Coverage Status| image:: http://img.shields.io/coveralls/Gwildor/Pyromancer.svg\n :target: https://coveralls.io/r/Gwildor/Pyromancer\n.. |MIT License| image:: https://img.shields.io/badge/license-MIT-green.svg\n :target: https://tldrlegal.com/license/mit-license", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Gwildor/Pyromancer", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "Pyromancer", "package_url": "https://pypi.org/project/Pyromancer/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/Pyromancer/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/Gwildor/Pyromancer" }, "release_url": "https://pypi.org/project/Pyromancer/1.0/", "requires_dist": null, "requires_python": null, "summary": "Simple framework for creating IRC bots", "version": "1.0" }, "last_serial": 1275165, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "e811fa672683639a5b5a04dda753e416", "sha256": "52792e4275e9b32e25c1dd75c364f64b032fc1b19cae147697398cae10e5b9a5" }, "downloads": -1, "filename": "Pyromancer-0.1.tar.gz", "has_sig": false, "md5_digest": "e811fa672683639a5b5a04dda753e416", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3986, "upload_time": "2013-11-17T21:24:28", "url": "https://files.pythonhosted.org/packages/44/5f/adf033c3eb4e4f62c618fa0e79803aee24d7e06bbd7ea0ee00e85e4e7269/Pyromancer-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "a95433970eecd00cf59e27824c7179b1", "sha256": "8a944cbdd28b130954aa08372795c903d45d7f0a60fbca166ad643ab7150571b" }, "downloads": -1, "filename": "Pyromancer-0.2.tar.gz", "has_sig": false, "md5_digest": "a95433970eecd00cf59e27824c7179b1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7064, "upload_time": "2014-03-22T14:03:43", "url": "https://files.pythonhosted.org/packages/4a/72/47f3165b8512485f1459d24caa5f60739ae4752892086dd5c00cd202076f/Pyromancer-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "ebcd3d3da65f84e1406f755f0897afc6", "sha256": "0a58b5ad6c4bebae758160fe851c0ba4cb9b94adf13c5b37b6f1b63ba8f47ad9" }, "downloads": -1, "filename": "Pyromancer-0.3.tar.gz", "has_sig": false, "md5_digest": "ebcd3d3da65f84e1406f755f0897afc6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7728, "upload_time": "2014-03-22T21:27:11", "url": "https://files.pythonhosted.org/packages/3c/24/0e07c96186a5090c6157a0a1c68cfe54b53f20cbc62107601df1e9961c47/Pyromancer-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "249d8e12a4fc196bf112e4fcdd6d93fa", "sha256": "82b04b2e5e0cb2fa702c4b0e502dd675e32c2a9c9fe00ccebd11dd3e4f86633c" }, "downloads": -1, "filename": "Pyromancer-0.4.tar.gz", "has_sig": false, "md5_digest": "249d8e12a4fc196bf112e4fcdd6d93fa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11046, "upload_time": "2014-03-30T16:04:04", "url": "https://files.pythonhosted.org/packages/cc/80/4fae0c481104a0a3678fe87e6bd1968eba136c6c7a21b4dbbeebbb9bcc37/Pyromancer-0.4.tar.gz" } ], "1.0": [ { "comment_text": "", "digests": { "md5": "25e110c4e1ecdd0dccb28042c722eb9c", "sha256": "5a91ace6b3e73edc316c1cd504aa30d0a2af016fff7fdc57bc7ef45a5c01f85f" }, "downloads": -1, "filename": "Pyromancer-1.0.tar.gz", "has_sig": false, "md5_digest": "25e110c4e1ecdd0dccb28042c722eb9c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14356, "upload_time": "2014-10-18T20:09:13", "url": "https://files.pythonhosted.org/packages/a3/d5/2c92e451f081a82ec6b3b3eb8761ada9a4cc23d2a77539d193a0005eb9b2/Pyromancer-1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "25e110c4e1ecdd0dccb28042c722eb9c", "sha256": "5a91ace6b3e73edc316c1cd504aa30d0a2af016fff7fdc57bc7ef45a5c01f85f" }, "downloads": -1, "filename": "Pyromancer-1.0.tar.gz", "has_sig": false, "md5_digest": "25e110c4e1ecdd0dccb28042c722eb9c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14356, "upload_time": "2014-10-18T20:09:13", "url": "https://files.pythonhosted.org/packages/a3/d5/2c92e451f081a82ec6b3b3eb8761ada9a4cc23d2a77539d193a0005eb9b2/Pyromancer-1.0.tar.gz" } ] }