如何使用Telethon与谷歌云功能

2024-10-01 00:16:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我是python新手,我想使用Telethon使用google云函数,但我不能这样做,因为我在运行时出错

以下是Gcloud功能代码我的代码:

from telethon import TelegramClient, events, sync
#from telethon import functions, types
#from telethon.tl.functions.channels import CreateChannelRequest, CheckUsernameRequest, UpdateUsernameRequest, InviteToChannelRequest
#from telethon.tl.types import InputChannel, InputPeerChannel

api_id = XXX
api_hash = 'XXX'

def hello_world(request):
    with TelegramClient("session_name", api_id, api_hash) as client:
        from telethon.tl.functions.channels import CreateChannelRequest, CheckUsernameRequest, UpdateUsernameRequest
        from telethon.tl.types import InputChannel, InputPeerChannel
        from telethon.tl.types import InputPhoneContact
        from telethon.tl.types import InputPeerUser
        from telethon.tl.functions.contacts import ImportContactsRequest

        contact = InputPhoneContact(client_id=11111, phone='1111111111', first_name="Twilo Test",last_name="Phone")

        newcontact = client(ImportContactsRequest(contacts=[contact]))

        return newcontact.__dict__;

My Requerements.txt:

# Function dependencies, for example:
# package>=version
telethon

当我运行函数(hello_world)时,我得到以下错误:

python google cloud error on running


Tags: 函数代码namefromimportclientapiid