S
S
s1veme2020-09-01 13:52:14
Python
s1veme, 2020-09-01 13:52:14

Does the function output nothing when imported?

There is a parse.py file :

from pyrogram import Client

app = Client("my_account", api_id=INT, api_hash=STR)

more_users = []
def user_chat():
    with app: 
        for member in app.iter_chat_members(INT):
            print(member)
            id_user = member.user.id
            more_users.append(id_user)
            username = member.user.first_name
        return more_users


There is a main.py file where parse.py is imported and the following code:
@bot.message_handler(commands = ["root"])
def root(message):
    admins_id = [INT]
    if message.from_user.id in admins_id:
        print(parse.user_chat())


All ID/Data - have been specially replaced by just a data type, everything is fine in the code and they are in place.

If you call user_chat in the parse.py file, then everything will be fine.
If you call user_chat in the main.py file, but not in the handler - but simply at the very beginning of the file - then everything will be fine and it will display what you need

. But if you call this function in the handler, then the following will simply appear in the console:
TgCrypto is missing! Pyrogram will work the same, but at a much slower speed. More info: https://docs.pyrogram.org/topics/tgcrypto

And then it will just wait for something (But as I understand it, parse is no longer waiting, but telebot is waiting for commands)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Belokurov, 2020-09-01
@kyern

Is there any reason in the parse file to keep app and more_users outside the user_chat function?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question