Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help!!! #7

Open
JordanKM3 opened this issue Jan 19, 2018 · 26 comments
Open

Help!!! #7

JordanKM3 opened this issue Jan 19, 2018 · 26 comments

Comments

@JordanKM3
Copy link

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
Copy link
Owner

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
Copy link
Author

Sorry i really new to python and stuff

@JordanKM3
Copy link
Author

how do you run it?

@robbiebarrat
Copy link
Owner

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
Copy link
Author

Ah im on windows

@robbiebarrat
Copy link
Owner

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
Copy link
Author

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
Copy link
Author

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

@robbiebarrat
Copy link
Owner

robbiebarrat commented Jan 20, 2018

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
Copy link
Author

Yeah the line of error are the keys i put in

@robbiebarrat
Copy link
Owner

robbiebarrat commented Jan 20, 2018

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

@JordanKM3
Copy link
Author

with the key?

@robbiebarrat
Copy link
Owner

robbiebarrat commented Jan 20, 2018

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
Copy link
Author

all it says is invalid syntax and that's all

@robbiebarrat
Copy link
Owner

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
Copy link
Author

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
Copy link
Author

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

@JordanKM3
Copy link
Author

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

@robbiebarrat
Copy link
Owner

have you installed tweepy with pip install tweepy?

@JordanKM3
Copy link
Author

um i think so

@robbiebarrat
Copy link
Owner

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
Copy link
Author

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

This is what i get on the python command line

@robbiebarrat
Copy link
Owner

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
Copy link
Author

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

@JordanKM3
Copy link
Author

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

@dimitrilap
Copy link
Collaborator

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

@JordanKM3 Did you add the key?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants