GithubHelp home page GithubHelp logo

botomatic's Introduction

botomatic

The botomatic package makes it easy to create Twitter bots in python. The package handles authentication, retrieving messages, processing the output, and publishing back to Twitter. I want to make it as easy as possible to create fun and creative bots. The world needs more awesome bots!

Usage

First, register the twitter account you want to use.

Second, subclass the TBot class. Overload the run method to process the input messages (via handle_messages()) and add any messages that you want to publish to the self.tweets list.

For our hello world example, say hi to a Magic 8 Ball bot (alive @dodecaDecider):

import random
from botomatic import TBot

RESPONSES = ['It is certain', 'It is decidedly so', 'Without a doubt', 'Yes definitely', 'You may rely on it', 'As I see it yes', 'Most likely', 'Outlook good', 'Yes', 'Signs point to yes', 'Reply hazy try again', 'Ask again later', 'Better not tell you now', 'Cannot predict now', 'Concentrate and ask again', 'Don\'t count on it', 'My reply is no', 'My sources say no', 'Outlook not so good', 'Very doubtful']

class Magic8Ball(TBot):
    debug_mode = False

    def __init__(self):
        handle = "dodecaDecider"
        super(Magic8Ball, self).__init__(handle)

    def run(self):
        for msg in self.handle_mentions():
            reply = "@%s %s" % (msg.user.screen_name, random.choice(RESPONSES))
            self.tweets.append((reply, msg.id))

        self.wrap_up()

Additional Information

You will need to create a file called "settings.py" containing the following:

BITLY_LOGIN = ""
BITLY_APIKEY = ""
CONSUMER_KEY = ""
CONSUMER_SECRET = ""

The CONSUMER_KEY and CONSUMER_SECRET can be obtained by registering the app at https://dev.twitter.com/apps and following the directions.

Dependencies

botomatic requires Tweepy

pip install Tweepy

botomatic's People

Contributors

hmason avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.