2017-11-08 8 views
1
import telebot 
import requests 
from telebot import types 
import time 
from datetime import datetime, date, time, timedelta 
import schedule 

pole = False 

TOKEN = '*******BOT TOKEN***********' 
bot = telebot.TeleBot(TOKEN) 

def job(): 

    pole=True 
    if pole == True: 
     bot.send_message(chat_id,'poleadaaaaa') 

schedule.every(10).minutes.do(job) 
schedule.every().hour.do(job) 
schedule.every().day.at("21:24").do(job) 

while 1: 
    schedule.run_pending() 
    time.sleep(1) 

def listener(messages): 
     for m in messages: 
      if m.content_type == 'text': 
       cid = m.chat.id 
       print ("[" + str(cid) + "]: " + m.text) 

bot.set_update_listener(listener) 

@bot.message_handler(commands=['start']) 

    bot.send_message(chat_id, 'Hello you start the bot') 


bot.polling(none_stop=True) 

に答えていない理由を私は次のコードを配置した場合ボットは「私はドンコマンドと任意のテキスト私は私のボットは、Pythonの電報で、このコードの後

def job(): 

     pole=True 
     if pole == True: 
      bot.send_message(chat_id,'poleadaaaaa') 

    schedule.every(10).minutes.do(job) 
    schedule.every().hour.do(job) 
    schedule.every().day.at("21:24").do(job) 

    while 1: 
     schedule.run_pending() 
     time.sleep(1) 

開始/答えていけないかわかりません私はこのコードを置くと私のボットが答えなかった理由を知っています。なぜなら、このコードがなければ、完璧に動作し、どんな場合でも答えが出ないからです。私はdef listener(messages):の前後にコードを入れて、@bot.message_handler(commands=['start'])の中に入れますが、ボットは何も答えません。

私を助けてください。ありがとうございました!! ....

実行別のスレッドでこの部分:

答えて

関連する問題