Code Monkey home page Code Monkey logo

markovbot's People

Contributors

esdalmaijer avatar kburk1997 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

markovbot's Issues

dict instead of list

typo in 'markovbot35.py'
not keys[i]
but key_list[i]
correct code:

                                # Try to find a word duo that contains the seed word
                                if seedword != None:
                                        # Loop through all potential seed words
                                        while len(seedword) > 0:
                                                # Loop through all keys (these are (w1,w2)
                                                # tuples of words that occurred together in the
                                                # text used to generate the database
                                                for i in range(len(keys)):
                                                        # If the seedword is only one word, check
                                                        # if it is part of the key (a word duo)
                                                        # If the seedword is a combination of words,
                                                        # check if they are the same as the key
                                                        if seedword[0] in key_list[i] or \
                                                                (tuple(seedword[0].split(u' ')) == \
                                                                key_list[i]):
                                                                # Choose the words
                                                                w1, w2 = key_list[i]
                                                                # Get rid of the seedwords
                                                                seedword = []
                                                                break

Feature request - random selection of suffix and prefix

Edwin, this is a great little utility. Thanks.

Would it be possible to pass a list of strings to twitter_autoreply_start and twitter_tweeting_start for suffix= and prefix= such that a random item from the list would be used?

markovbot crash with "MSG frException in thread auto tweeter"

Hi @esdalmaijer
First, thank you for a great bot!

Every few days markovbot crashes with the following error:

MSG frException in thread autotweeter:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/emilioxavier/markovbot/markovbot27.py", line 1221, in _autotweet
    self._error(u'_autotweet', u"Failed to post a tweet! Error: '%s'" % (e))
  File "/home/emilioxavier/markovbot/markovbot27.py", line 1384, in _error
    raise Exception(u"ERROR in Markovbot.%s: %s" % (methodname, msg))
Exception: ERROR in Markovbot._autotweet: Failed to post a tweet! Error: 'Twitter sent status 403 for URL: 1.1/statuses/update.json using parameters: (oauth_consumer_key=REMOVED&oauth_nonce=REMOVED&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1513398340&oauth_token=REMOVED&oauth_version=1.0&status=Using%20MD%20simulation%20was%20used%20for%20learning.%20Results%20show%20how%20the%20intersection%20between%20two%20vertices%20of%20%CE%93.%20&oauth_signature=REMOVED)
details: {u'errors': [{u'message': u'Status is a duplicate.', u'code': 187}]}'

Any ideas what might be causing the error and crash? Does the error mean markovbot cannot reach the internet? The bot is running on a RaspberryPi (Linux hindbaer 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l GNU/Linux) and connects to the internet over wifi. Please let me know if you need more information.

Thank you for your help!
Emilio

Missing database in Markovbot._autoreply

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!

Last use of `unicode` in the Python 3.5 version

In line 510, a list of values is converted to a list of unicode values:

responses = map(unicode, list(respdict[targetstring]))

This should be:

responses = map(str, list(respdict[targetstring]))

(Might also be good to update the comments.)

Would you mind picking this up, @kburk1997? :)

TwitterStream can disconnect

The Twitter library will sometimes return {'hangup':True} instead of a typical tweet dictionary. This occurs on a Stream SSLError (see this commit in the twitter library). Calling on an iterator after this disconnect will cause a StopIteration exception.

This will crash the _autoreplythread, which assumes certain keys will be in the tweet dict. In addtion, it relies on a working TwitterStream. Two changes are necessary to fix this:

  1. Check before line 690 whether 'hangup' in tweet.keys(). If it is, the TwitterStream should be restarted (see change 2), and the current tweet should not be processed.
  2. Add a _reanimate method to restart the Twitter connection. To be safe, restart both _t (Twitter login) and _ts (TwitterStream).

NOTE: A call to _reanimate should also be added to _autotweet's try-except for posting a new Tweet.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.