bots: Move contrib_bots to api/bots*.
This will make it convenient to include these bots in Zulip API releases on pypi. Fix #5009.
This commit is contained in:
parent
7531c4fb26
commit
894adb1e43
110 changed files with 36 additions and 27 deletions
0
bots/helloworld/__init__.py
Normal file
0
bots/helloworld/__init__.py
Normal file
18
bots/helloworld/helloworld.py
Normal file
18
bots/helloworld/helloworld.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# See readme.md for instructions on running this code.
|
||||
|
||||
|
||||
class HelloWorldHandler(object):
|
||||
def usage(self):
|
||||
return '''
|
||||
This is a boilerplate bot that responds to a user query with
|
||||
"beep boop", which is robot for "Hello World".
|
||||
|
||||
This bot can be used as a template for other, more
|
||||
sophisticated, bots.
|
||||
'''
|
||||
|
||||
def handle_message(self, message, client, state_handler):
|
||||
content = 'beep boop'
|
||||
client.send_reply(message, content)
|
||||
|
||||
handler_class = HelloWorldHandler
|
4
bots/helloworld/readme.md
Normal file
4
bots/helloworld/readme.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
Simple Zulip bot that will respond to any query with a "beep boop".
|
||||
|
||||
The helloworld bot is a boilerplate bot that can be used as a
|
||||
template for more sophisticated/evolved Zulip bots.
|
23
bots/helloworld/test_helloworld.py
Normal file
23
bots/helloworld/test_helloworld.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
from six.moves import zip
|
||||
|
||||
our_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.insert(0, os.path.normpath(os.path.join(our_dir)))
|
||||
# For dev setups, we can find the API in the repo itself.
|
||||
if os.path.exists(os.path.join(our_dir, '..')):
|
||||
sys.path.insert(0, '..')
|
||||
from bots_test_lib import BotTestCase
|
||||
|
||||
class TestHelloWorldBot(BotTestCase):
|
||||
bot_name = "helloworld"
|
||||
|
||||
def test_bot(self):
|
||||
txt = "beep boop"
|
||||
messages = ["", "foo", "Hi, my name is abc"]
|
||||
self.check_expected_responses(dict(list(zip(messages, len(messages)*[txt]))))
|
Loading…
Add table
Add a link
Reference in a new issue