update documentation

pull/29/head
Mallory Hancock 2018-02-05 16:38:53 -08:00
parent afb9cc7f12
commit 708d5146e8
6 changed files with 69 additions and 3 deletions

View File

@ -7,7 +7,7 @@ a pluggable irc bot framework in python
$ pip install pinhook $ pip install pinhook
``` ```
### Creating the Bot ### Creating an IRC Bot
To create the bot, just create a python file with the following: To create the bot, just create a python file with the following:
```python ```python
@ -28,6 +28,31 @@ Optional arguments are:
* `ops`: list of operators who can do things like make the bot join other channels or quit (default: empty list) * `ops`: list of operators who can do things like make the bot join other channels or quit (default: empty list)
* `plugin_dir`: directory where the bot should look for plugins (default: "plugins") * `plugin_dir`: directory where the bot should look for plugins (default: "plugins")
* `log_level`: string indicating logging level. Logging can be disabled by setting this to "off". (default: "info") * `log_level`: string indicating logging level. Logging can be disabled by setting this to "off". (default: "info")
* `ns_pass`: this is the password to identify with nickserv
* `server_pass`: password for the server
* `ssl_required`: boolean to turn ssl on or off
### Creating a Twitch Bot
Pinhook has a baked in way to connect directly to a twitch channel
```python
import pinhook.bot
bot = pinhook.bot.TwitchBot(
nickname='ph-bot',
channel='#channel',
token='super-secret-oauth-token'
)
bot.start()
```
This function has far less options, as the server, port, and ssl are already handled by twitch.
Optional aguments are:
* `ops`
* `plugin_dir`
* `log_level`
These options are the same for both IRC and Twitch
### Creating plugins ### Creating plugins
In your chosen plugins directory ("plugins" by default) make a python file with a function. You can use the `@pinhook.plugin.register` decorator to tell the bot the command to activate the function. In your chosen plugins directory ("plugins" by default) make a python file with a function. You can use the `@pinhook.plugin.register` decorator to tell the bot the command to activate the function.

View File

@ -13,8 +13,8 @@ Installation
$ pip install pinhook $ pip install pinhook
Creating the Bot Creating an IRC Bot
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
To create the bot, just create a python file with the following: To create the bot, just create a python file with the following:
@ -42,6 +42,36 @@ Optional arguments are:
(default: "plugins") (default: "plugins")
- ``log_level``: string indicating logging level. Logging can be - ``log_level``: string indicating logging level. Logging can be
disabled by setting this to "off". (default: "info") disabled by setting this to "off". (default: "info")
- ``ns_pass``: this is the password to identify with nickserv
- ``server_pass``: password for the server
- ``ssl_required``: boolean to turn ssl on or off
Creating a Twitch Bot
~~~~~~~~~~~~~~~~~~~~~
Pinhook has a baked in way to connect directly to a twitch channel
.. code:: python
import pinhook.bot
bot = pinhook.bot.TwitchBot(
nickname='ph-bot',
channel='#channel',
token='super-secret-oauth-token'
)
bot.start()
This function has far less options, as the server, port, and ssl are
already handled by twitch.
Optional aguments are:
- ``ops``
- ``plugin_dir``
- ``log_level``
These options are the same for both IRC and Twitch
Creating plugins Creating plugins
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~

View File

@ -0,0 +1,4 @@
import pinhook.bot
bot = pinhook.bot.TwitchBot('ph-bot', '#example', 'supersecrettokenhere')
bot.start()

View File

@ -0,0 +1,7 @@
import pinhook.plugin
@pinhook.plugin.register('!test')
def test(msg):
msg.logger.info('This is test log output')
return pinhook.plugin.message("{}: Test".format(msg.nick))