-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved sicial adapters into the adapter module.
- Loading branch information
1 parent
19b3eb0
commit f2e469d
Showing
8 changed files
with
99 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
from .io import IOAdapter | ||
from .terminal import TerminalAdapter | ||
from .twitter import TwitterAdapter | ||
from .github import GitHubAdapter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
chatterbot/apis/twitter.py → chatterbot/adapters/io/twitter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
''' | ||
Check for online mentions on social media sites. | ||
Respond to mentions on twitter. | ||
The bot will follow the user who mentioned it and | ||
favorite the post in which the mention was made. | ||
''' | ||
|
||
from chatterbot.apis.twitter import Twitter | ||
chatbot = ChatBot("ChatterBot", | ||
storage_adapter="chatterbot.adapters.storage.JsonDatabaseAdapter", | ||
logic_adapter="chatterbot.adapters.logic.ClosestMatchAdapter", | ||
io_adapter="chatterbot.adapters.io.TwitterAdapter", | ||
database="../database.db") | ||
|
||
chatbot = ChatBot("ChatterBot") | ||
for mention in chatbot.get_mentions(): | ||
|
||
if "twitter" in kwargs: | ||
twitter_bot = Twitter(kwargs["twitter"]) | ||
''' | ||
Check to see if the post has been favorited | ||
We will use this as a check for whether or not to respond to it. | ||
Only respond to unfavorited mentions. | ||
''' | ||
|
||
for mention in twitter_bot.get_mentions(): | ||
if not mention["favorited"]: | ||
screen_name = mention["user"]["screen_name"] | ||
text = mention["text"] | ||
response = chatbot.get_response(text) | ||
|
||
''' | ||
Check to see if the post has been favorited | ||
We will use this as a check for whether or not to respond to it. | ||
Only respond to unfavorited mentions. | ||
''' | ||
print(text) | ||
print(response) | ||
|
||
if not mention["favorited"]: | ||
screen_name = mention["user"]["screen_name"] | ||
text = mention["text"] | ||
response = chatbot.get_response(text) | ||
chatbot.follow(screen_name) | ||
chatbot.favorite(mention["id"]) | ||
chatbot.reply(mention["id"], response) | ||
|
||
print(text) | ||
print(response) | ||
|
||
follow(screen_name) | ||
favorite(mention["id"]) | ||
reply(mention["id"], response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters