robbiebarrat / twitter-contest-enterer

Twitter bot that mass-enters contests on twitters, and (mostly) avoids bot-detection accounts.
MIT License
135 stars 24 forks source link

Help!!! #7

Open JordanKM3 opened 6 years ago

JordanKM3 commented 6 years ago

I have put in all the keys and when i run it says "There's an error in your program: Invalid syntax" Please help

robbiebarrat commented 6 years ago

How are you trying to run it? you should be using python twitterbot.py from the command line...

is that the full error message?

JordanKM3 commented 6 years ago

Sorry i really new to python and stuff

JordanKM3 commented 6 years ago

how do you run it?

robbiebarrat commented 6 years ago

don't worry about it man - are you on windows or on linux?

if you're on linux you can just open up a new terminal in the directory of wherever your program is, and type python twitterbot.py into the terminal and it will run, but on windows you might have to do extra things.

JordanKM3 commented 6 years ago

Ah im on windows

robbiebarrat commented 6 years ago

install python from python.org - and then use this guide (it's a very good guide)

http://effbot.org/pyfaq/how-do-i-run-a-python-program-under-windows.htm

if you have any more questions just post them here - i'll try to respond as quick as i can

JordanKM3 commented 6 years ago

ah i don't know man i go on the python command line and type python twitterbot.py and i still get syntaxerror: invalid syntax

JordanKM3 commented 6 years ago

do i have to edit the twitterbot.py cause i have and put put all my keys in

robbiebarrat commented 6 years ago

yeah you're supposed to put all of your keys in - can you paste the full error?? does it point to a line or anything?

are you running it on the actual python command line, where it starts with >>> ? if so; that's the wrong place, you need to type it into your command prompt at the windows shell (should say C:/> at the start of each line or something)

JordanKM3 commented 6 years ago

Yeah the line of error are the keys i put in

robbiebarrat commented 6 years ago

paste those lines here, please? like the lines where you put the keys in

JordanKM3 commented 6 years ago

with the key?

robbiebarrat commented 6 years ago

oh crap yeah that's right - you probably shouldn't paste that here; i forgot the keys were private...

can you make sure that you have quotes on either side of all of your keys? Also; does the error message say anything more specific? usually it will elaborate on invalid syntax and it will say something like missing quote or something...

JordanKM3 commented 6 years ago

all it says is invalid syntax and that's all

robbiebarrat commented 6 years ago

alright, i can't help you very much with the provided info but check these:

  1. there are quotes on each side of each key and they are the same type of quotes (e.g. both ' or both ". doesn't matter which as long as they're both the same

  2. there is an equals sign in each line before the quoted key

  3. there isn't anything outside of the quotes on each line before the # and the comment

maybe post the lines here but when you post them just replace your keys with the word "key" so i can see a little bit of what's going on?

JordanKM3 commented 6 years ago

This was a quick project. Inspired by a story I heard of on the news where a guy did something almost exactly the same

and won a bunch of stuff. I couldn't find the code that that guy used (I don't think he wanted to release it), so I

wrote this. Have fun.

import tweepy, time

enter the corresponding information from your Twitter application:

CONSUMER_KEY = ''key'' #keep the quotes, enter your consumer key CONSUMER_SECRET = ''key'' #keep the quotes, enter your consumer secret key ACCESS_KEY = ''key'' #keep the quotes, enter your access token ACCESS_SECRET = ''key'' #keep the quotes, enter your access token secret

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) auth.set_access_token(ACCESS_KEY, ACCESS_SECRET) api = tweepy.API(auth, wait_on_rate_limit=True,wait_on_rate_limit_notify=True) keywords = ["rt to", "rt and win", "retweet and win", "rt for", "rt 4", "retweet to"]

bannedwords = ["vote", "bot", "b0t"]

bannedusers = ['bot', 'spot', 'lvbroadcasting'] # does not need to be the entire username! you can just put 'bot' for names like 'b0tspotter', etc.

def is_user_bot_hunter(username): clean_username = username.replace("0", "o") clean_username = clean_username.lower() for i in bannedusers: if i in clean_username: return True else: return False

def search(twts): for i in twts: if not any(k in i.text.lower() for k in keywords) or any(k in i.text.lower() for k in bannedwords): continue if is_user_bot_hunter(str(i.author.screen_name)) == False: if not i.retweeted: try: api.retweet(i.id) print "rt " + (i.text)

                if "follow" in i.text or "Follow" in i.text or "FOLLOW" in i.text:
                    user_id = i.retweeted_status.user.id
                    api.create_friendship(user_id)

            except Exception:
                pass

        if ("fav" in i.text or "Fav" in i.text or "FAV" in i.text) and not i.favorited:
            try:
                api.create_favorite(i.id)
                print "fav " + (i.text)
            except Exception:
                pass

def run(): for key in ["RT to win", "retweet to win"]: print "\nSearching again\n" search(api.search(q=key))

if name == 'main': while True: run()

JordanKM3 commented 6 years ago

when i run the command on IDLE there is a red line on my keys that i put in

JordanKM3 commented 6 years ago

i have tried running the command on python and the IDLE thing

robbiebarrat commented 6 years ago

have you installed tweepy with pip install tweepy?

JordanKM3 commented 6 years ago

um i think so

robbiebarrat commented 6 years ago

can you please paste in the error you get when you try to run the program, you can replace your keys with key but just let me see the entirety of the 'incorrect syntax' error

JordanKM3 commented 6 years ago

python twitterbot.py File "", line 1 python twitterbot.py ^ SyntaxError: invalid syntax

This is what i get on the python command line

robbiebarrat commented 6 years ago

you can't run it on the python command line; that's for when you want to run code, so i could type something like print 'hello' and python would interpret that command. it's giving you that error because it expects you to feed it python code.

you need to just open up a normal command prompt (windows key + R, type cmd, hit enter) and enter in python [path-to-twitterbot.py]

with [path-to-twitterbot.py] being where the python file is saved, so if it's in your downloads folder you could type python C:\Users\JordanKM3\Downloads\twitterbot.py (or however your paths are laid out - haven't used windows in a long time so i dont really remember)

if this fails, look up "how to run a python program in idle" and follow the steps you see there.

JordanKM3 commented 6 years ago

File "twitterbot.py", line 9 CONSUMER_KEY = ''key'' #keep the quotes, enter your consumer key ^ SyntaxError: invalid syntax

JordanKM3 commented 6 years ago

I found out how to run program but its takes me back the the SyntaxError

dimitrilap commented 6 years ago

File "twitterbot.py", line 9 CONSUMER_KEY = ''key'' #keep the quotes, enter your consumer key ^ SyntaxError: invalid syntax

@JordanKM3 Did you add the key?