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:
Rohitt Vashishtha 2017-05-30 11:40:19 +05:30 committed by Tim Abbott
parent 7531c4fb26
commit 894adb1e43
110 changed files with 36 additions and 27 deletions

View file

View 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

View 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.

View 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]))))