0
我有一個腳本,它響應發送給句柄的推文。問題是在終端開始時只運行一次,並停止工作。我已經安排它使用Python調度器運行每分鐘,但它不工作。Python腳本不調度
import sched, time, tweepy
#from our keys module (keys.py), import the keys dictionary
from keys import keys
s = sched.scheduler(time.time, time.sleep)
def run_thejewels(sc):
CONSUMER_KEY = keys['consumer_key']
CONSUMER_SECRET = keys['consumer_secret']
ACCESS_TOKEN = keys['access_token']
ACCESS_TOKEN_SECRET = keys['access_token_secret']
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
api = tweepy.API(auth)
twt = api.search(q='@twitterhandle')
#list of specific strings we want to check for in Tweets
t = ['TLOP',
'FS4',
'ULB']
u = ['HL',
'FSMH',
'FADE']
for s in twt:
for i in t:
if i in s.text:
sn = s.user.screen_name
m = "@%s Hello bruv" % (sn)
s = api.update_status(m, s.id)
for p in twt:
for j in u:
if j in p.text:
pn = p.user.screen_name
m = "@%s Hello bro" % (pn)
p = api.update_status(m, p.id)
s.enter(60, 1, run_thejewels, (s,))
s.run()