- A small bot that utilizes praw and chatterbot to connect to multiple services
- chatterbot: https://github.com/gunthercox/ChatterBot
- PRAW: https://praw.readthedocs.io/en/latest/
- python 3.5+
- Be sure to export envars first:
export REDDIT_CLIENT_ID=
export REDDIT_CLIENT_SECRET=
export REDDIT_USERNAME=
export REDDIT_PASSWORD=
export TWITTER_KEY=
export TWITTER_SECRET=
export TWITTER_TOKEN=
export TWITTER_TOKEN_SECRET=
export HIPCHAT_HOST=
export HIPCHAT_ROOM=
export HIPCHAT_ACCESS_TOKEN=
export GITTER_ROOM=
export GITTER_API_TOKEN=
- Edward
- Dependencies
- Usage
- Docker
- Module defs
- bot_on_bot()
- bot_sploit()
- chat_bot()
- emoji_preprocessor(bot, statement)
- english_training()
- facebook_messenger_bot()
- feedback_bot()
- feedback(bot, comment)
- get_gitter_envars()
- get_hipchat_envars()
- get_reddit_envars()
- get_reddit()
- get_sub_comments(comment)
- get_twitter_envars()
- gitter_bot()
- hipchat_bot()
- logging_setup()
- loop_trainer(input_s)
- main()
- reddit_training(sub, lim)
- twitter_bot()
- twitter_training()
- ubuntu_training()
- voice_bot()
- word_list_training()
- TODO
Usage:
./edward.py [-l <level> | --level <level>]
[-t <type> | --training <type>]
[-b <bot> | --bot <bot>]
[-e | --export <file>]
[-h | --help ]
[--version ]
Options:
-h --help Show this screen and exit
--version Show version and exit
-l --level=<level> [default: info]
-t --training=<type> Training type:
english, word_list,
ubuntu, reddit, twitter
[default: None]
-b --bot=<bot> Run bot: [default: help]
gitter, hipchat, voice, feedback
[default: None]
Build and test with docker-compose
make test
Build and deploy to docker swarm
make deploy
docke
8000
r stack services edward
ID NAME MODE REPLICAS IMAGE PORTS
i3laoiilqi76 edward_mongo replicated 1/1 mongo:latest *:27017->27017/tcp
qyio6ac50xyt edward_bot replicated 1/1 bot:latest
- make bot talk to another bot.
- https://www.tolearnenglish.com/free/celebs/audreyg.php
- Search for other bots on reddit
- Talk to the other bots on reddit
- https://github.com/gunthercox/ChatterBot
- Create default bot
- return chatbot
- input emojis to chatterbot
- http://chatterbot.readthedocs.io/en/stable/preprocessors.html
- http://www.unicode.org/emoji/charts/full-emoji-list.html
- gunthercox/ChatterBot#911
- get base bot chat_bot()
- train basic english with
- chatterbot.corpus.english
- Connect to facebook messenger
- API key?:
- ask for input
- present input_statement and response to user
- ask if it makes sense
- if no, user can fix
- train bot
- parse comment for Master commands
- return response
- get Gitter room and api token from envars
- obtain an api token at:
- https://developer.gitter.im/apps
- return gitter_room, gitter_api_token
- get HipChat host, room, and api token from envars
- obtain an api token at:
- https://hipchat.com/admin/api
- return hipchat_host, hipchat_room, hipchat_access_token
- get Reddit creds from envars
- return client_id, client_secret, username, password
- obtain client_id, client_secret, username, password from get_reddit_envars()
- set reddit to praw.Reddit
- return reddit
- get sub comments from a reddit comment object as a list
- generate a list of sub_comments from all replies
- return sub_comments
- get Twitter creds from envars
- return twitter_key, twitter_secret, twitter_token, twitter_token_secret
- create app https://apps.twitter.com/
- get gitter_room, gitter_api_token from get_gitter_envars()
Talk to bot with twitter or github access
DOES NOT WORK YET
- setup logging
- return logger
-
input_s
str
required
default = None
Input string
- input string
- process as input_statement
- get statement and response form chat bot
- if the response is not the same as the input string
- train bot with conversation
- check docopt args
-
sub
str
optional
default = 'all'
Which subreddit to use
-
lim
int
optional
default = 9
how many to grab
Configure
- get base bot chat_bot()
- get reddit from get_reddit()
- configure read only true/false
- sub = the subreddit to use
- lim = the amount of submissions to grab from a chosen subreddit
- slp = is set to keep from reaching reddit server rate limits
Training
- training list starts as an empty list []
- for every submission collect comment chains
- for every comment in comment chains collect all replies
- if the comment is not '[deleted]'
- if reply is not '[removed]'
- if reply is < 80 characters
- append training list
- Train the bot
- Create a BotStreamListener(StreamListener) class
- see details here: class StreamListener(object):
- Start up bot on init()
- watch for data
- if 'direct_message' and not our user_id:
- process a response for the message from the database
- reply with response
Train bot using data from Twitter.
- THIS IS BROKEN RIGHT NOW
- get base bot chat_bot()
- train with ubuntu corpus
- chatterbot.corpus.ubuntu
- see Training with the Ubuntu dialog corpus
- input speech to text
- output text to speech
- word_list contains 5000 most common words in English language
- randomize the list
- pool 4 child processes
- run loop_trainer(input_s) with word as input s
- Rate limiting fixes
- pytest
- stack overflow