basti2342 / retweet-bot

Retweets tweets mentioning your hashtag/search query. Supports Twitter API v1.1.
Mozilla Public License 2.0
127 stars 96 forks source link

Attribute error #5

Closed erangatennakoon closed 9 years ago

erangatennakoon commented 9 years ago

Hi,

I got the following error;

AttributeError: 'filter' object has no attribute 'reverse'

on the following line;

timeline.reverse()

Can you please help me to sort it out.

erangatennakoon commented 9 years ago

I'm using python v3.4.2

basti2342 commented 9 years ago

Hi erangatennakoon,

in Python3 filter() returns a filter object that's iterable but no list. Before reversing it, you have to transform it to a list.

Change line 56 from timeline.reverse() to timeline = reversed(list(timeline))

Maybe I'll release a Python3 version as a separate branch in the future.

Hope that helps, basti2342

erangatennakoon commented 9 years ago

Hi basti2342.

It works fine, without any error. Thanks for the quick update.

I've noticed one thing. Each time when I run the code it didn't RT any tweet. There are new tweets with the hashtag that I've define. Can you please help me on that too. I did all the configurations as you explained.

basti2342 commented 9 years ago

So it doesn't retweet anything at all? That's bad. Does it list any tweets when you run it?

I don't know what modifications you made to make it work with Python3, so it's hard to say what's wrong. I just pushed my Python3 version to a new branch. check it out and tell me if that works for you.

If it's not working, your search_query config line could be helpful.

Regards, basti2342

erangatennakoon commented 9 years ago

I did a mistake, put as follows on line 56 of the original source

list(timeline).reverse()

Update the same source to Python3 and it works fine. Now I've to do some changes like continuous loop and stuff. I'll give a try and let you know in case.

Thanks a lot again.

erangatennakoon commented 9 years ago

My idea is to do the followings;

  1. Search with more than one hashtag, rather one.
  2. Continuous loop
basti2342 commented 9 years ago

I did a mistake, put as follows on line 56 of the original source

list(timeline).reverse()

That fixes the error, but it's useless. You reverse a temporary list of timeline that'll never get used anywhere. The timeline doesn't get reversed and the save point/last id's are not working as expected. Please have a look at my comment above.

My idea is to do the followings;

  1. Search with more than one hashtag, rather one.

This is already possible, but the config option is misleading. You can put any search query there, e.g.

beer OR wine from:whoever

Please have a look at https://search.twitter.com/ (especially "operators" and "advanced search"). You can use all of that.

  1. Continuous loop

You're free to do so, but have a look at the rate limits. I decided not to implement a continous loop, because I prefer to call a Python script via crontab (or something similar) rather than have a script with static sleep times running all the time.

Regards, basti2342

erangatennakoon commented 9 years ago

Yes I agree. I'll try my best to keep in the safe side and do this.

Thanks again for your help. I'll close this issue soon.