热解图回调函数

如何解决热解图回调函数

根据 Pyrogram 库文档,我正在尝试使用可调用函数设置“phone_code”参数,但我总是收到此错误,有人可以帮助我吗?

    if (msg.startsWith(prefix + "prune") || msg.startsWith(prefix + "purge") || msg.startsWith(prefix + "delete")) {

        ...

        var embedERRPRUNE5 = new discord.MessageEmbed()
        .setColor("#8c00ee")
        .setTitle("❌Something went wrong,while deleting messages.")
        .setAuthor("Vittorio De STradis ツ","https://cdn.discordapp.com/attachments/784128595084705853/790590227277545502/Cowboy_Bepop_1.png","...")
        
        .setFooter("If you need help,pls contact me!","https://cdn.discordapp.com/attachments/784128595084705853/790590227277545502/Cowboy_Bepop_1.png")
        .setTimestamp();

        var embedPRUNE = new discord.MessageEmbed()
        .setColor("#8c00ee")
        .setTitle(`✔ Deleted ${message.size}/${args[0]} messages.`)
        .setAuthor("Vittorio De STradis ツ","https://cdn.discordapp.com/attachments/784128595084705853/790590227277545502/Cowboy_Bepop_1.png")
        .setTimestamp();

        await message.delete()
        await message.channel.bulkDelete(args[0])
        .then(message => message.channel.send(embedPRUNE)).then(d => d.delete({timeout: 15000})) // In quanto tempo questo messaggio verrà eliminato (in ms).
        .catch(() => message.channel.send(embedERRPRUNE5)) // Questo errore comparirà quando il bot non ha l'accesso per farlo.
    }```

错误

from pyrogram import Client
import time

def codePhone(phone_number):
    print('numero')
    sleep (10)
    return '2154'

app = Client("my_account",phone_number='39**********',phone_code=codePhone)
with app:
    app.send_message("me","Hi!")

解决方法

对不起,我不认为我完全理解这里的要求,但从它的外观来看,您需要让它工作。因此,在这种情况下,您需要了解将什么作为参数传递给函数。

由于 codePhone 函数接受一个参数 (phone_number),但在您的 Client 类中,您只是将其作为回调引用发送,这似乎是不正确的。

此外,根据模块 (Pyrogram) here 的文档,phone_code 参数需要是字符串(很可能是数字字符串 -> '2154')。因此,请尝试使用它。

告诉我这是否适合您。

TL;DR:使用

app = Client("my_account",phone_number='39**********',phone_code='2154')
,

您使用的是 1.0.7 版,但support for callback functions for parameters for Client was removed in ver. 0.16.0

删除了对客户端参数的回调函数的支持,例如 phone_number,phone_code,password,... 支持更简单和 顺序授权流程。

目前它希望您为 str 提供 phone_code

, phone_number 类中的

Client 参数采用字符串,而不是函数。如果您想自动化电话号码登录的过程:

from pyrogram import Client
from pyrogram.errors import SessionPasswordNeeded
import os

api_id    = input('API ID: ')
api_hash  = input('API HASH: ')
phone     = input('Phone Number (with +): ')

def connect():
    try:
        client = Client(phone,api_id,api_hash)
        client.connect()
        code   = client.send_code(phone)
        try:
            signed_in = client.sign_in(phone,code.phone_code_hash,input('Verification Code: '))
            client.accept_terms_of_service(signed_in.id)
        except SessionPasswordNeeded:
            client.check_password(input('Two-Step Verification password: '))
        client.disconnect()
    except Exception as ex:
        os.remove(f'{phone}.session')
        print(f'Error !\n\t`{type(ex).__name__}`\n\t{ex}')
        return

    with client as app:
        app.send_message('me',"Hey it's YOU!")

if __name__ == '__main__':
    connect()

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?