Welcome to Bot-Chucky’s documentation!

v0.0.3 (Github)

Bot-Chucky is a Facebook Messenger Bot API, capable of interacting with the user, providing integration with Twitter, Gmail, SoundCloud, StackExchange and weather updates.

Contents

Installation

At the command line:

pip install bot_chucky

Note: Support for Python 3.6+.

User Guide

If you want test your application on a local machine:

Chucky currently provides:

  • Send message
  • Send weather information
  • Search SoundCloud, based on artist
  • Search StackExchange for answers
  • Generate own flow

Search SoundCloud, based on artist/Search StackExchange for answers/Generate own flow will be available in a new version.

This list will be expanded.

Examples

  • Flask example:

    from flask import Flask, request
    
    from bot_chucky.bot import BotChucky
    from bot_chucky.utils import get_sender_id, get_user_text
    
    token = 'YOUR_FACEBOOK_PAGE_TOKEN'
    
    # Init a Flask app
    app = Flask(__name__)
    
    # Create an instance of Chucky object
    # If you want to send weather information
    # You need to set your Open Weather API key
    bot = BotChucky(token, open_weather_token='YOUR_OPEN_WEATHER_TOKEN')
    
    
    @app.route('/', methods=['GET'])
    def handle_verification():
    # Verify your facebook PAGE.
    return request.args['hub.challenge']
    
    
    @app.route('/', methods=['POST'])
    def handle_messages():
    data = request.json
    if data['object'] == 'page':
        for entry in data['entry']:
            for event in entry.get('messaging'):
                if event.get('message'):
                    # Get a user id
                    sender_id = get_sender_id(data)
    
                    # Get a user text
                    text = get_user_text(data)
    
                    # NOTICE: if you want send message to a user
                    # use send_message function
                    # if you want to send a weather info
                    # use only send_weather_info function
                    bot.send_message(sender_id, text)
                    bot.send_weather_message(sender_id, text)
    
                if event.get('delivery'):
                    pass
    
    return 'ok', 200
    
    
    if __name__ == '__main__':
    app.run(debug=True)
    

bot_chucky

Bot-Chucky package

Submodules
bot_chucky.bot module
bot_chucky.constants module

Constants file

bot_chucky.errors module

Exception classes

exception bot_chucky.errors.BotChuckyError(msg)[source]

Bases: exceptions.Exception

exception bot_chucky.errors.BotChuckyInvalidToken[source]

Bases: exceptions.Exception

exception bot_chucky.errors.BotChuckyTokenError(api_name)[source]

Bases: exceptions.Exception

bot_chucky.helpers module
bot_chucky.test module
bot_chucky.utils module
Module contents

Contribution

  • Fork or clone repository
  • Create a branch such as feature/bug/refactor and send a Pull request