Найти - Пользователи
Полная версия: ребят помогите,не запускается код на примере печалька бота
Начало » Python для новичков » ребят помогите,не запускается код на примере печалька бота
1
sixty_seven
#coding: utf-8
import oauth, tweepy, sys, locale, threading
from time import localtime, strftime, sleep

replyed=
search_reply_words={'печалька':' каждый раз, когда вы говорите “печалька”, умирают хомячки.','пичалька':' каждый раз, когда вы говорите “пичалька”, умирают хомячки.'}
update_time=60 #время обновления

def Tweet(twit,id_reply):
if len(twit)<=140 and len(twit)>0:
api.update_status(twit,id_reply) #обновляем статус (постим твит)
return True
else:
return False

def init(): #инициализируемся
global api
#consumer_key = “”
#consumer_secret = “”
#access_key=“”
#access_secret=“”
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_key, access_secret)
api=tweepy.API(auth)

class TwiBot(threading.Thread):
def __init__ (self, keyword,answer):
self.keyword = keyword
self.answer=answer
threading.Thread.__init__(self)

def run (self):
global replyed,api
request=api.search(self.keyword) #ищем твиты с указанным словом
for i in request:
if i.from_user!='thevar1able' and i.id not in replyed: # если твит не наш и мы на него еще не отвечали…
try:
Tweet('@'+i.from_user+self.answer,i.id) #…отвечаем
print strftime('',localtime())+' Reply to @'+i.from_user+'('+str(i.from_user_id)+')'
except:
print strftime('DUP ',localtime())+' Reply to @'+i.from_user+'('+str(i.from_user_id)+')'
replyed.append(i.id)
return True



init() # инициализируемся
while not False: # вечно
for word in search_reply_words:
TwiBot(word, search_reply_words).start() #запускаем поток с нужным словом для поиска
print strftime('',localtime())+' Updating for word “'+str(word)+'”…'
sleep(1)
sleep(update_time
sixty_seven
syntax error
undident does not match any outher indentation level
PEHDOM
sixty_seven у вас косяк с отступами, о чем вам честно говорл интерпретатор, выложите код в тегах
[code python][/code]
чтобы были видны отступы, тогда можно будет сказать чтото определенное.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB