Slide 1

Slide 1 text

Supercharge your chat! By @NickGroenen

Slide 2

Slide 2 text

I do… DevOps

Slide 3

Slide 3 text

Tools and Process

Slide 4

Slide 4 text

Wrong!

Slide 5

Slide 5 text

People problem, tech problem

Slide 6

Slide 6 text

Communication

Slide 7

Slide 7 text

Text chat

Slide 8

Slide 8 text

Human <-> computer interaction

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

Credits: http://matadornetwork.com/abroad/metric-map-which-countries-dont-belong-with-the-others/

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

Are you finished deploying yet? Can I deploy mine? Who deployed that last change? Did you see that Nagios alert? Who's looking into it? Did you see issue 205? Issue 205? Yeah it's that issue about midnight being false. Oh, that one! Yes I saw it.

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

Err The pluggable chat-bot http://errbot.net/ https://github.com/gbin/err

Slide 16

Slide 16 text

Err is a GPL3-licensed chat bot for Jabber XMPP and IRC networks, designed to be easily deployable, extendable and maintainable.

Slide 17

Slide 17 text

Supports Python 2.7 and Python 3.3+ Platform independent (yes, Windows!)

Slide 18

Slide 18 text

Pluggable & emphasis on sharing

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

Simple but powerful

Slide 21

Slide 21 text

from errbot import BotPlugin, botcmd class HelloWorld(BotPlugin): """Example 'Hello, world!' plugin for Err""" @botcmd def hello(self, msg, args): """Say hello to the world""" return "Hello, world!"

Slide 22

Slide 22 text

from errbot import BotPlugin, botcmd class HelloWorld(BotPlugin): """Example 'Hello, world!' plugin for Err""" @botcmd def hello(self, msg, args): """Say hello to the world""" return "Hello, world!"

Slide 23

Slide 23 text

from errbot import BotPlugin, botcmd class HelloWorld(BotPlugin): """Example 'Hello, world!' plugin for Err""" @botcmd def hello(self, msg, args): """Say hello to the world""" return "Hello, world!"

Slide 24

Slide 24 text

from errbot import BotPlugin, botcmd class HelloWorld(BotPlugin): """Example 'Hello, world!' plugin for Err""" @botcmd def hello(self, msg, args): """Say hello to the world""" return "Hello, world!"

Slide 25

Slide 25 text

from errbot import BotPlugin, botcmd class HelloWorld(BotPlugin): """Example 'Hello, world!' plugin for Err""" @botcmd def hello(self, msg, args): """Say hello to the world""" return "Hello, world!"

Slide 26

Slide 26 text

from errbot import BotPlugin, botcmd class HelloWorld(BotPlugin): """Example 'Hello, world!' plugin for Err""" @botcmd(name="helloworld") def hello(self, msg, args): """Say hello to the world""" return "Hello, world!"

Slide 27

Slide 27 text

from errbot import BotPlugin, botcmd class HelloWorld(BotPlugin): """Example 'Hello, world!' plugin for Err""" @botcmd def hello(self, msg, args): """Say hello to the world""" return "Hello, world!"

Slide 28

Slide 28 text

from errbot import BotPlugin, botcmd class HelloWorld(BotPlugin): """Example 'Hello, world!' plugin for Err""" @botcmd def hello(self, msg, args): """Say hello to the world""" return "Hello, world!"

Slide 29

Slide 29 text

@botcmd def hello(self, msg, args): """Say hello to the world""" return "Hello, world!" msg.frm -> "[email protected]/Nick Groenen"

Slide 30

Slide 30 text

@botcmd def hello(self, msg, args): """Say hello to the world""" return "Hello, world!" msg.frm -> "[email protected]/Nick Groenen" msg.type_ -> "groupchat"

Slide 31

Slide 31 text

@botcmd def hello(self, msg, args): """Say hello to the world""" return "Hello, world!" msg.frm -> "[email protected]/Nick Groenen" msg.type_ -> "groupchat" msg.body -> "!hello"

Slide 32

Slide 32 text

@botcmd def hello(self, msg, args): """Say hello to the world""" return "Hello, world!" msg.frm -> "[email protected]/Nick Groenen" msg.type_ -> "groupchat" msg.body -> "!hello" msg.html -> None

Slide 33

Slide 33 text

@botcmd def hello(self, msg, args): """Say hello to the world""" return "Hello, world!" msg.frm -> "[email protected]/Nick Groenen" msg.type_ -> "groupchat" msg.body -> "!hello" msg.html -> None msg.to -> "[email protected]/Err Bot"

Slide 34

Slide 34 text

@botcmd def hello(self, msg, args): """Say hello to the world""" return "Hello, world!" !hello -> args = ""

Slide 35

Slide 35 text

@botcmd def hello(self, msg, args): """Say hello to the world""" return "Hello, world!" !hello -> args = "" !hello Err Bot -> args = "Err Bot"

Slide 36

Slide 36 text

@botcmd(split_args_with=None) def hello(self, msg, args): """Say hello to the world""" return "Hello, world!"

Slide 37

Slide 37 text

@botcmd(split_args_with=None) def hello(self, msg, args): """Say hello to the world""" return "Hello, world!" !hello Err Bot -> args = ["Err", "Bot"]

Slide 38

Slide 38 text

Returning multiple responses from errbot import BotPlugin, botcmd from time import sleep class PluginExample(BotPlugin): @botcmd def longcompute(self, mess, args): yield "Going to sleep" sleep(10) yield "Waking up"

Slide 39

Slide 39 text

Returning multiple responses from errbot import BotPlugin, botcmd from time import sleep class PluginExample(BotPlugin): @botcmd def longcompute(self, mess, args): yield "Going to sleep" sleep(10) yield "Waking up"

Slide 40

Slide 40 text

Templates hello.html: {% extends "base.html" %} {% block body %}

Hello, {{name}}!

{% endblock %}

Slide 41

Slide 41 text

Templates from errbot import BotPlugin, botcmd class Hello(BotPlugin): @botcmd(template="hello") def hello(self, msg, args): """Say hello to someone""" return {'name': args}

Slide 42

Slide 42 text

Templates from errbot import BotPlugin, botcmd class Hello(BotPlugin): @botcmd(template="hello") def hello(self, msg, args): """Say hello to someone""" return {'name': args}

Slide 43

Slide 43 text

Webhooks from errbot import BotPlugin, webhook import logging class PluginExample(BotPlugin): @webhook def example(self, incoming_request): logging.debug(repr(incoming_request)) return "OK"

Slide 44

Slide 44 text

Webhooks from errbot import BotPlugin, webhook import logging class PluginExample(BotPlugin): @webhook def example(self, incoming_request): logging.debug(repr(incoming_request)) return "OK"

Slide 45

Slide 45 text

Webhooks $ curl -i http://localhost:3141/example HTTP/1.1 200 OK Content-Length: 2 Content-Type: text/html; charset=UTF-8 Date: Tue, 05 Aug 2014 01:40:01 GMT Server: Rocket 1.2.4 Python/3.3.2+ Connection: keep-alive OK

Slide 46

Slide 46 text

Webhooks from errbot import BotPlugin, webhook import logging class PluginExample(BotPlugin): @webhook(r'/custom_uri/.*/') def example(self, incoming_request): logging.debug(repr(incoming_request)) return "OK"

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

Extensive configuration # Allow everyone access by default ACCESS_CONTROLS_DEFAULT = {} ACCESS_CONTROLS = { 'status': {'allowrooms': ('[email protected],)}, 'about': {'denyusers': ('[email protected],), 'uptime': {'allowusers': BOT_ADMINS}, }

Slide 49

Slide 49 text

Extensive configuration DIVERT_TO_PRIVATE = ('help', 'about', 'status')

Slide 50

Slide 50 text

Tests (pytest) from errbot.backends.test import \ testbot, push_message, pop_message extra_plugin_dir = '/foo/bar' def test_about(testbot): push_message('!about') assert "Err version" in pop_message()

Slide 51

Slide 51 text

Tests (stdlib unittest) from errbot.backends.test import \ FullStackTest, push_message, pop_message class TestCommands(FullStackTest): def setUp(self): super().setUp(extra_plugin_dir='/foo/bar') def test_about(self): push_message('!about') self.assertIn("Err version", pop_message())

Slide 52

Slide 52 text

http://errbot.net/user_guide/plugin_development/

Slide 53

Slide 53 text

Questions?