Open JordanKM3 opened 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?
Sorry i really new to python and stuff
how do you run it?
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.
Ah im on windows
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
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
do i have to edit the twitterbot.py cause i have and put put all my keys in
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)
Yeah the line of error are the keys i put in
paste those lines here, please? like the lines where you put the keys in
with the key?
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...
all it says is invalid syntax and that's all
alright, i can't help you very much with the provided info but check these:
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
there is an equals sign in each line before the quoted key
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?
import tweepy, time
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()
when i run the command on IDLE there is a red line on my keys that i put in
i have tried running the command on python and the IDLE thing
have you installed tweepy with pip install tweepy
?
um i think so
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
python twitterbot.py File "
", line 1 python twitterbot.py ^ SyntaxError: invalid syntax This is what i get on the python command line
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.
File "twitterbot.py", line 9 CONSUMER_KEY = ''key'' #keep the quotes, enter your consumer key ^ SyntaxError: invalid syntax
I found out how to run program but its takes me back the the SyntaxError
File "twitterbot.py", line 9 CONSUMER_KEY = ''key'' #keep the quotes, enter your consumer key ^ SyntaxError: invalid syntax
@JordanKM3 Did you add the key?
I have put in all the keys and when i run it says "There's an error in your program: Invalid syntax" Please help