Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 电报类型错误:第一个参数必须是可调用的_Python_Arguments_Scheduled Tasks_Telegram - Fatal编程技术网

Python 电报类型错误:第一个参数必须是可调用的

Python 电报类型错误:第一个参数必须是可调用的,python,arguments,scheduled-tasks,telegram,Python,Arguments,Scheduled Tasks,Telegram,我正试着用电报发送自动时间表。它第一次运行,但在尝试循环后,我得到一个错误: TypeError:第一个参数必须是可调用的 我的代码: import time import schedule from pyrogram import Client, ReplyKeyboardMarkup, InlineKeyboardMarkup, InlineKeyboardButton from pyrogram.api import functions, types from pyrogram.api.e

我正试着用电报发送自动时间表。它第一次运行,但在尝试循环后,我得到一个错误:

TypeError:第一个参数必须是可调用的

我的代码:

import time
import schedule
from pyrogram import Client, ReplyKeyboardMarkup, InlineKeyboardMarkup, InlineKeyboardButton
from pyrogram.api import functions, types
from pyrogram.api.errors import FloodWait


person1 = Client(
    session_name="*cenzored*",
    api_id=*cenzored*,
    api_hash="*cenzored*"
)

person2 = Client(
    session_name="*cenzored*",
    api_id=*cenzored*,
    api_hash="*cenzored*"
)
wick.start()

def Publish(session,dat,msgid,session_name):
    try:
        session.start()
        print("[%s]Posting..." % (session_name))
        session.send(
            functions.messages.GetBotCallbackAnswer(
                peer=session.resolve_peer("*cenzored*"),         
                msg_id=msgid,
                data=b'publish %d' % (dat)
            )
        )
        session.idle()
    except:
        print("Crashed,starting over")

schedule.every(0.3).minutes.do(Publish(person1,142129,12758, 'Dani')) // Here is the line is crashing.
schedule.every(0.3).minutes.do(Publish(person2,137351,13177, 'Wick'))

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

Pyrogram v0.7.4, Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
Licensed under the terms of the GNU Lesser General Public License v3 or later (LGPLv3+)

[person1]Posting...
3: 2018-06-16 12:07:26.529829 Retrying <class 'pyrogram.api.functions.messages.get_bot_callback_answer.GetBotCallbackAnswer'>
4: 2018-06-16 12:07:42.041309 Retrying <class 'pyrogram.api.functions.messages.get_bot_callback_answer.GetBotCallbackAnswer'>
Crashed,starting over
Traceback (most recent call last):
  File "C:\Users\343df\OneDrive\Desktop\Maor\python\tele\tele.py", line 35, in <module>
    schedule.every(0.3).minutes.do(Publish('ss',dani,140129,12758, 'Dani'))
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\schedule\__init__.py", line 385, in do
    self.job_func = functools.partial(job_func, *args, **kwargs)
TypeError: the first argument must be callable
Pyrogram v0.7.4,版权所有(C)2017-2018 Dan Tès
根据GNU Lesser General Public License v3或更高版本(LGPLv3+)的条款许可
[person1]发布。。。
3:2018-06-16 12:07:26.529829重试
4:2018-06-16 12:07:42.041309重试
崩溃了,重新开始
回溯(最近一次呼叫最后一次):
文件“C:\Users\343df\OneDrive\Desktop\Maor\python\tele\tele.py”,第35行,在
每(0.3)分钟安排一次(发布('ss',dani,14012912758,'dani'))
do中的文件“C:\Program Files(x86)\Python36-32\lib\site packages\schedule\\uuuuu init\uuuuu.py”,第385行
self.job_func=functools.partial(job_func,*args,**kwargs)
TypeError:第一个参数必须是可调用的
基本上,我的问题是在第一次之后没有运行(
TypeError:第一个参数必须是可调用的,并且它计划每0.3秒运行一次。

根据,您不必调用发布,只需传递它,然后是它的参数列表(调用将由调度框架执行):

schedule.every(0.3).minutes.do(Publish,Person114212912758,“Dani”)
每(0.3)分钟做一次日程安排(发布,第23735113177页,“威克”)
.do()
作为第一个参数的可调用参数(以及
.do
的附加参数将传递给该可调用参数)

因此,不是:

schedule.every(0.3).minutes.do(Publish(person1,142129,12758, 'Dani'))
schedule.every(0.3).minutes.do(Publish(person2,137351,13177, 'Wick'))
您可能想要:

schedule.every(0.3).minutes.do(Publish, person1, 142129, 12758, 'Dani')
schedule.every(0.3).minutes.do(Publish, person2, 137351, 13177, 'Wick')

@罗甘约什补充道