Re: [Tutor] Responding Tweet: A Twitter Bot
Zaki Akhmad Wrote in message: > On Thu, Feb 20, 2014 at 7:39 PM, James Scholes wrote: > >> Most decent Python libraries for accessing Twitter support the streaming >> API. This lets you keep a connection to the Twitter API alive and >> process new data as it is received. There is a simple (but out-of-date) >> example on using streaming with the twitter package you linked to: >> https://pypi.python.org/pypi/twitter/1.13.1 > > My question is: how to execute this streaming API? > > My current approach is using cron to execute python script which has > "check the streaming API" function: > > def check_mention: > if (mention): > tweet > > If I want to check every minute, then I should configure cron to > execute this script every minute. Are there any other approach besides > using cron? > > > > import time while True: do|something time.sleep (60) Note that sleep () doesn't hog the processor; very nearly 100% of the processor is given to the other processes. Further, you don't have the startup time you'd have with cron. There are tradeoffs, but sleep is usually what you want. -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Responding Tweet: A Twitter Bot
On Thu, Feb 20, 2014 at 7:39 PM, James Scholes wrote: > Most decent Python libraries for accessing Twitter support the streaming > API. This lets you keep a connection to the Twitter API alive and > process new data as it is received. There is a simple (but out-of-date) > example on using streaming with the twitter package you linked to: > https://pypi.python.org/pypi/twitter/1.13.1 My question is: how to execute this streaming API? My current approach is using cron to execute python script which has "check the streaming API" function: def check_mention: if (mention): tweet If I want to check every minute, then I should configure cron to execute this script every minute. Are there any other approach besides using cron? -- Zaki Akhmad ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Responding Tweet: A Twitter Bot
On 20/02/14 08:23, Zaki Akhmad wrote: I am trying to create a twitter bot which respond mentions as soon as possible. Here's the detail. These have been around for a long time in email circles. One thing to watch is detection of cycles. That's where someone tweets you and you auto-respond, But they also have an auto-responder that responds to your automated message. Will your program then respond to that too? If so you get a cycle with an infinite loop of auto responses. That's not a good thing. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] constructing semi-arbitrary functions
On 02/20/2014 01:56 AM, "André Walker-Loud " wrote: On Feb 19, 2014, at 7:45 PM, André Walker-Loud wrote: OK - I have not seen an email from Peter. So I looked up the thread online, and see I did not receive half the emails on this thread :O My first inclination was to blame my mac mavericks mail gmail syncing problem. but logging into gmail, I see no record of the emails there either. I currently receive the tutor emails in the digest mode - thought I was paying attention to all the digests - but I seems to have missed many. I apologize to all those who offered input whose emails I missed - I certainly wasn’t ignoring them. and as a follow up - is there a way to download a thread from the tutor archive? I am guessing the answers are one of 1) write a python script to grab the emails associated with the threads from the web 2) download the whole gzip’d text and use python to grab only the parts I want but 1) I haven’t done that before and unfortunately don’t have time to learn now 2) some combination of being too busy and lazy prevents me from this option… Your local email client, if any, may do 90% of the job for you if you set: * normal, non-digest mode * threaded view locally then just press 'del' on every other thread. As a side-note, since you are now subscribed to the python-tutor list, by not pressing 'del' (too quiclkly), you may learn much about python and programming in general, in a both nice and efficient manner. d ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Responding Tweet: A Twitter Bot
Hello, I am trying to create a twitter bot which respond mentions as soon as possible. Here's the detail. If @someone mention my account @example then in t seconds I would respond @someone tweet. I am hoping to get this t less than 60 seconds. I would utilize the Mike Verdone twitter API python[1]. My question is how to get the mentions as soon as possible, as @someone mention @example? Any python library could help me? Hint please. Previously, I use cron to search for tweets that mentioned @example account. [1]https://pypi.python.org/pypi/twitter Thank you, -- Zaki Akhmad ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor