一个基于 Ruby 的简洁的 Twitter Bot 框架,使用 OAuth 进行身份验证。
Hi friends, I'm finally archiving this project as of March 2023. I really enjoyed using and maintaining Chatterbot, and I hope it was helpful for other people too. ❤️
Hey! This is Chatterbot 2.0. There have been some breaking changes from older versions of the library, and it doesn't support MySQL anymore. If you are looking for the old version, you can try the 1.0 branch
Chatterbot has a documentation website. It's a work-in-progress. You can also read the gem documentation.
First thing you'll need to do is create an account for your bot on Twitter. That's the easy part.
Chatterbot comes with a script named chatterbot-register which will
handle two tasks -- it will authorize your bot with Twitter and it
will generate a skeleton script, which you use to implement your
actual bot.
A bot using chatterbot can be as simple as this:
exclude "http://"
blocklist "mean_user, private_user"
puts "checking my timeline"
home_timeline do |tweet|
# i like to favorite things
favorite tweet
end
puts "checking for replies to my tweets and mentions of me"
replies do |tweet|
text = tweet.text
puts "message received: #{text}"
src = text.gsub(/@echoes_bot/, "#USER#")
# send it back!
reply src, tweet
endOr you can write a bot using more traditional ruby classes, extend it if needed, and use it like so:
…rb loop do search "twitter" do |tweet| # here you could do something with a tweet # if you want to retweet retweet(tweet.id) end
replies do |tweet| # do stuff end
sleep 60 end
Blocklists
----------
Not everyone wants to hear from your bot. To keep annoyances to a
minimum, Chatterbot has a simple blocklist tool. Using it is as simple as:
blocklist "mean_user, private_user"
You should really respect the wishes of users who don't want to hear
from your bot, and add them to your blocklist whenever requested.
There's also an 'exclude' method which can be used to add
words/phrases you might want to ignore -- for example, if you wanted
to ignore tweets with links, you could do something like this:
exclude "http://"
Contributing to Chatterbot
--------------------------
Pull requests for bug fixes and new features are eagerly accepted.
Since this code is based off of actual Twitter bots, please try and
maintain compatability with the existing codebase. If you are
comfortable writing a spec for any changed code, please do so. If not,
I can work with you on that.
Copyright/License
-----------------
Copyright (c) 2018 Colin Mitchell. Chatterbot is distributed under the
MIT licence -- Please see LICENSE.txt for further details.
http://muffinlabs.com暂无开放 Issues,或尚未同步最近议题。