[英]Telegram TypeError: the first argument must be callable
I'm trying to do post automatic schedule in Telegram. 我正在尝试在Telegram中发布自动计划。 It runs first run but after its try to looping I get an error:
它首先运行,但尝试循环后出现错误:
TypeError: the first argument must be callable
TypeError:第一个参数必须是可调用的
My code : 我的代码:
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)
Traceback : 追溯 :
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
Basically my problem is that is not running ( TypeError: the first argument must be callable
) after first time and its scheduled to run every 0.3 seconds. 基本上我的问题是第一次运行后没有运行(
TypeError: the first argument must be callable
),并且计划每0.3秒运行一次。
According to [ReadTheDocs]: do ( job_func, *args, **kwargs ) , you don't have to call Publish , but just pass it, followed by its argument list (the call will be performed by schedule framework): 根据[ReadTheDocs]: do ( job_func,* args,** kwargs ) ,您不必调用 Publish ,而只需传递它,然后传递其参数列表(该调用将由调度框架执行):
schedule.every(0.3).minutes.do(Publish, person1, 142129, 12758, "Dani")
schedule.every(0.3).minutes.do(Publish, person2, 137351, 13177, "Wick")
.do()
expects a callable as the first argument (and additional arguments to .do
will be passed to that callable). .do()
期望可调用对象作为第一个参数(并且.do
其他参数将传递给该可调用对象)。
So instead of: 所以代替:
schedule.every(0.3).minutes.do(Publish(person1,142129,12758, 'Dani'))
schedule.every(0.3).minutes.do(Publish(person2,137351,13177, 'Wick'))
you likely want: 您可能想要:
schedule.every(0.3).minutes.do(Publish, person1, 142129, 12758, 'Dani')
schedule.every(0.3).minutes.do(Publish, person2, 137351, 13177, 'Wick')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.