Coder Social home page Coder Social logo

handcartcactus / nlp-bot Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 131 KB

An interactive twitter bot that runs a variety of profile analysis commands. Used to be live at https://twitter.com/WhatDoITweetBot. Temporarily offline.

Home Page: https://twitter.com/WhatDoITweetBot

License: MIT License

Python 100.00%
twitter-bot twitter python bot

nlp-bot's Introduction

TwitterBot

Code relating to my twitter bot, which can be found here.

Interacting with the bot

For more information on interacting with the bot, see USERGUIDE.md.

Setup

Fork it!

Fork it.

API Tokens

Get your Twitter api tokens.

Config File

Create a copy of configs/template.ini as configs/config.ini and store your credentials in it.

Conda Env

In the root directory of the project, create your conda env with conda env create -f twitterbot.yml.

Running The Code

conda activate twitterbot
python client.py --config configs/config.ini

Development

The Command Class

To create commands for your bot:

  1. Create a Command subclass using the Command Abstract Base Class.
  2. Import the command into client.py
  3. Add the command to the commands_dict in client.py along with a string alias for twitter users.

Your Command subclass will recieve:

  1. The Twitter API
  2. The Tweet ID
  3. The User ID
  4. Any text following the command, for parameters.

Your subclass should implement a reply_tweet() method that probably calls another method to do a thing, then prepares a response and tweets it back at the user.

For Example, you might make a class like this:

class MyCommand (Command):
    def _do_something(self):
        #do something
        return 100

    def _format_output(self, result):
        # string format it or whatever
        return str(result)
    
    def reply_tweet(self):
        something = self._do_something()
        text = self._format_output(something)
        self.api.PostUpdate(
            status=text, 
            in_reply_to_status_id=self.tweet_id, 
            auto_populate_reply_metadata=True
        )

Then you can add it to client.py's commands_dict like this:

from my_commands import MyCommand

commands_dict = {
    'my_command': MyCommand,
}

And you should be good to go!

Use

Tweet at your bot using the following format: "@bot command (params)"

nlp-bot's People

Contributors

handcartcactus avatar

Stargazers

Richard Bankole avatar

Watchers

 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.