나는이 봇으로 거의 끝났습니다. tweepy API를 통해 출력을 자동화하는 데 도움이 필요합니다. 나는 3 개의 함수를 가지고 있는데, 목록에서 처음 2 개의 임의 문장을 얻었고, 3 번째 함수는 2 개를 무작위로 번갈아 나타낼 것이다. 내 문제는 내 트위터 봇에 세 번째 기능의 출력물을 인쇄하는 것입니다. api.update_status()
은 물론 sleep
을 사용한다고 가정하지만 문서를 읽은 후에도 내 기능을 사용하는 방법을 모르겠습니다. 나는 당신의 문제를 잘 알고 아닙니다마무리 트위터 봇의 자동화
# -*- coding: utf-8 -*-
import random
import tweepy
from time import sleep
from credentials import *
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
def sentence_type():
words = [["sentence1","sentence2","sentence3"],
["conjunction1","conjunction2","conjunction3"],
["sentence1, sentence2, sentence3],
["sentence1, sentence2, sentence3"]]
print(' '.join([random.choice(w) for w in words]))
def sentence_type_2():
words = [["sentence1","sentence2","sentence3"],
["conjunction1","conjunction2","conjunction3"],
["sentence1, sentence2, sentence3],
["sentence1, sentence2, sentence3"]]
print(' '.join([random.choice(w) for w in words]))
def get_Sentence():
num = random.randrange(1, 3)
if num == 1:
sentence_type()
elif num == 2:
sentence_type_2()
get_Sentence()
그래서 난 그냥 이것으로 내 정보를 연결 것이고, 내 코드에 어딘가에 붙여? 내 주요 문제는 내 함수 출력으로 봇의 상태를 업데이트 할 수 없다는 것입니다.이 형식을 사용하면 출력을 자동화 할 수 있습니까? – spitnik11