esdalmaijer / markovbot

Library to generate text with a Markov chain, with support to read and post updates to Twitter accounts.
http://www.pygaze.org/2016/03/how-to-code-twitter-bot/
GNU General Public License v3.0
141 stars 64 forks source link

Missing database in Markovbot._autoreply #2

Closed james-nichols closed 8 years ago

james-nichols commented 8 years ago

MSG from Markovbot._autoreply: James Nichols (@james_nichols): .@MalcolmTurnbot What do you think about agility? #HeyTurnbot MSG from Markovbot._autoreply: I found seedwords: '['agility']'. Exception in thread autoreplier: Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/Users/james/projects/malcolm_turnbot/markovbot/markovbot.py", line 888, in _autoreply response = self._construct_tweet(database=database, \ UnboundLocalError: local variable 'database' referenced before assignment Normal auto-tweeting works fine, so a database certainly is in there. Looking in to it now to suggest fix. PS thanks for the excellent Markov generator!

esdalmaijer commented 8 years ago

Woops, that's my bad! For a temporary fix, change your call to twitter_autoreply_start to include database=u'auto-language' keyword. Example:

tweetbot.twitter_autoreply_start(targetstring, database=u'auto-language', keywords=None, prefix=None, suffix=None, maxconvdepth=None, mindelay=1.5)

Thanks for the compliment! Great to see people are using it :)

esdalmaijer commented 8 years ago

TODO: Add the following to complete the if statement that starts on line 828:

else:
    database = self._autoreply_database
esdalmaijer commented 8 years ago

This issue should be solved by the latest commit. Would you mind downloading the newest code, and checking whether it works?