K
K
Kendric Folkin2020-11-20 20:46:54
Python
Kendric Folkin, 2020-11-20 20:46:54

How can I make the function appear in the main script?

I created my own library, made the following function in it:

def free():
  client = FreeKassaApi(
    first_secret='',
    second_secret='',
    merchant_id='',
    wallet_id='')
  balance = client.get_balance()


Now go to the main script of the VK bot, how can I make it so that when the free-kassa message is
displayed, the "balance" variable from my library is displayed.
elif body.lower() == "free-kassa ":
          if sg.adminAut(id, "data/admin.txt") == 1:
            vk.method("messages.send", {"peer_id": id, "message": str("test"), "random_id": random.randint(1, 2147483647)})
          else:
            vk.method("messages.send", {"peer_id": id, "message": str(admno),
                          "random_id": random.randint(1, 2147483647)})


My library is imported into the main code
Free-kassa's library is imported into the main code

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alan Gibizov, 2020-11-20
@kendric

As a matter of fact:
I think that it is necessary, firstly, that the function returns the value of the desired variable. For example, using return
Second, there is a feeling that it would not hurt the function to accept some parameters, for example, all these secrets, id, etc. and pass them to the class to create the desired object and return it through return
Thirdly, I don’t see where balance is used in the code, but in fact you just need to call the function correctly and get the value it returns (apparently, an instance of the class).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question