-
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.
Kwargs are now passed to io adapter.
- Loading branch information
1 parent
ea32fa5
commit bdd547e
Showing
5 changed files
with
37 additions
and
33 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
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 |
---|---|---|
|
@@ -37,3 +37,4 @@ | |
|
||
except (KeyboardInterrupt, EOFError, SystemExit): | ||
break | ||
|
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,31 @@ | ||
''' | ||
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 import ChatBot | ||
|
||
|
||
chatbot = ChatBot("ChatterBot", | ||
storage_adapter="chatterbot.adapters.storage.JsonDatabaseAdapter", | ||
logic_adapter="chatterbot.adapters.logic.ClosestMatchAdapter", | ||
io_adapter="chatterbot.adapters.io.TwitterAdapter", | ||
database="../database.db") | ||
database="../database.db", | ||
consumer_key="xxx", | ||
consumer_secret="xxx" | ||
) | ||
|
||
''' | ||
Respond to mentions on twitter. | ||
The bot will follow the user who mentioned it and | ||
favorite the post in which the mention was made. | ||
''' | ||
|
||
for mention in chatbot.get_mentions(): | ||
user_input = "Type something to begin..." | ||
|
||
''' | ||
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(user_input) | ||
|
||
if not mention["favorited"]: | ||
screen_name = mention["user"]["screen_name"] | ||
text = mention["text"] | ||
response = chatbot.get_response(text) | ||
while True: | ||
try: | ||
user_input = chatbot.get_input() | ||
|
||
print(text) | ||
print(response) | ||
bot_input = chatbot.get_response(user_input) | ||
|
||
chatbot.follow(screen_name) | ||
chatbot.favorite(mention["id"]) | ||
chatbot.reply(mention["id"], response) | ||
except (KeyboardInterrupt, EOFError, SystemExit): | ||
break | ||
|
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