Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Bot replies to same Tweet every time script runs #8

Closed
amrit opened this issue Sep 9, 2012 · 8 comments
Closed

Bot replies to same Tweet every time script runs #8

amrit opened this issue Sep 9, 2012 · 8 comments

Comments

@amrit
Copy link

amrit commented Sep 9, 2012

How do I make sure the bot doesn't reply to the same tweet every time?

The following loop replies to tweets it has already replied to each time the script runs.

replies do |tweet|
  reply "Hi #USER#, thanks for your interest.", tweet
end
@muffinista
Copy link
Owner

Can I see your whole script?
On Sep 9, 2012 1:27 AM, "Amrit Ayalur" notifications@github.com wrote:

How do I make sure the bot doesn't reply to the same tweet every time?

The following loop replies to tweets it has already replied to each time
the script runs.

replies do |tweet|
reply "Hi #USER#, thanks for your interest.", tweetend


Reply to this email directly or view it on GitHubhttps://github.com//issues/8.

@amrit
Copy link
Author

amrit commented Sep 11, 2012

Sure thing!

#!/usr/bin/env ruby

require 'rubygems'
require 'chatterbot/dsl'

verbose


replies do |tweet|
  reply "Hi #USER#, thanks for your interest.", tweet
end

@muffinista
Copy link
Owner

When you run this, do you get any errors? Also, are you using a database to store your config or is it in a YAML file?

@amrit
Copy link
Author

amrit commented Sep 13, 2012

I don't get any errors. I'm not storing my config anywhere - should I?

@muffinista
Copy link
Owner

Yeah, I'm actually confused as to what is happening here. I just tested your code, and it runs fine with a proper config (see https://twitter.com/echoes_bot/status/247765604021465088 for the tweet). I would recommend that you run chatterbot-register and create a new bot from scratch, and see if that helps.

@staringispolite
Copy link

@muffinista I have this same problem. I assume it's because the bot's config isn't written to file or DB like you said above. How would I configure that? (Sorry if this is a standard Ruby thing - not new to programming, but new to Ruby)

EDIT: Got it working. In case anyone in the future is in my position, here's what worked.

  • Make a mysql database and user for your bot; give that bot user all privileges for that database (and only that database unless you're feeling lucky)
  • Save any edits to your bot.rb and bot.yml files in a temporary place and delete the originals.
  • Re-create the skeleton with ./bin/chatterbot-register -d <mysql URI here>
  • Re-auth and re-enter your bot data. You should see mysql info in the output.
  • Make sure your new .yml now has a line for :db_uri:. If not, add it.
  • Merge changes back to bot.rb
  • Remove or comment out the no_update line in bot.rb
  • Run it twice with debug on; in the bot's output, make sure the "check for replies since ___" number updates

You should see some output like "storing config to database -- you don't need local file anymore"

(Note that you'll still need the .yml file to tell it the db_uri, otherwise it'll prompt for API_KEY and such all over again)

@muffinista
Copy link
Owner

Glad you got it working! I actually removed db support in the 2.0 version of chatterbot -- it was difficult to use and maintain.

@staringispolite
Copy link

@muffinista Neat! Does it persist to the YML file in 2.0? I'd actually prefer that IMHO, just couldn't see how to get that working.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants