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/followup/__init__.py
Normal file
0
bots/followup/__init__.py
Normal file
46
bots/followup/followup.py
Normal file
46
bots/followup/followup.py
Normal file
|
@ -0,0 +1,46 @@
|
|||
# See readme.md for instructions on running this code.
|
||||
|
||||
class FollowupHandler(object):
|
||||
'''
|
||||
This plugin facilitates creating follow-up tasks when
|
||||
you are using Zulip to conduct a virtual meeting. It
|
||||
looks for messages starting with '@mention-bot'.
|
||||
|
||||
In this example, we write follow up items to a special
|
||||
Zulip stream called "followup," but this code could
|
||||
be adapted to write follow up items to some kind of
|
||||
external issue tracker as well.
|
||||
'''
|
||||
|
||||
def usage(self):
|
||||
return '''
|
||||
This plugin will allow users to flag messages
|
||||
as being follow-up items. Users should preface
|
||||
messages with "@mention-bot".
|
||||
|
||||
Before running this, make sure to create a stream
|
||||
called "followup" that your API user can send to.
|
||||
'''
|
||||
|
||||
def handle_message(self, message, client, state_handler):
|
||||
if message['content'] == '':
|
||||
bot_response = "Please specify the message you want to send to followup stream after @mention-bot"
|
||||
client.send_reply(message, bot_response)
|
||||
else:
|
||||
bot_response = self.get_bot_followup_response(message)
|
||||
client.send_message(dict(
|
||||
type='stream',
|
||||
to='followup',
|
||||
subject=message['sender_email'],
|
||||
content=bot_response,
|
||||
))
|
||||
|
||||
def get_bot_followup_response(self, message):
|
||||
original_content = message['content']
|
||||
original_sender = message['sender_email']
|
||||
temp_content = 'from %s: ' % (original_sender,)
|
||||
new_content = temp_content + original_content
|
||||
|
||||
return new_content
|
||||
|
||||
handler_class = FollowupHandler
|
Loading…
Add table
Add a link
Reference in a new issue