简体   繁体   English

电报TypeError:第一个参数必须可调用

[英]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]: dojob_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.

相关问题 TypeError:第一个参数必须是可调用的 - TypeError: first argument must be callable TypeError:第一个参数必须是可调用的 - TypeError: the first argument must be callable 类型错误:第一个参数必须在调度程序库中可调用 - TypeError: the first argument must be callable in scheduler library TypeError:第一个参数必须是可调用的,defaultdict - TypeError: first argument must be callable, defaultdict 调度库 TypeError:第一个参数必须是可调用的 - Schedule library TypeError: the first argument must be callable Pandas 造型为 excel “TypeError:第一个参数必须是可调用的” - Pandas styling to excel “TypeError: the first argument must be callable” 第一个参数必须是可调用的或无 - first argument must be callable or None 类型错误:第一个参数必须是可调用的或无 - 错误不是第一次出现而是稍后出现 - TypeError: first argument must be callable or None - error is not coming first time but coming later TypeError:当我在django的views.py文件中导入调度程序时,第一个参数必须是可调用的? - TypeError: the first argument must be callable when I import a scheduler in my views.py file of django? TypeError:deafultdict必须具有可调用的第一个参数 - TypeError: deafultdict must have first arguments callable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM