MasterCruelty / robbot

My personal Telegram bot made in Python. It has several features and it's based on Pyrogram.
MIT License
18 stars 1 forks source link

[*.0] 🐛 Fix conflict between two different buttons #87

Open MasterCruelty opened 2 years ago

MasterCruelty commented 2 years ago

Typing /urban argument1 and then /urban argument2 will be resulting in a conflict because if you press the button of the first command you get the next page of argument1 but if you press the button of the second command, you get still the next page of argument1 instead of argument2.

I used /urban as an example but the problem is intended in every function that uses Inline buttons.

urban.py

MasterCruelty commented 2 years ago

Edit: This problem is probably linked with using global variables

Kd-Here commented 2 years ago

Can i help you in that @MasterCruelty ?

MasterCruelty commented 2 years ago

Can i help you in that @MasterCruelty ?

Of course you can! Here you find a few guidelines to contribute to the project. (The first step is done because there's already an issue) These are the files affected: weather.py, lyrics.py, urban.py

Do you have any idea to do this?

Kd-Here commented 2 years ago

Currently I don't have any idea for now. But I will run code in my system first after checking function I get the idea 👍

MasterCruelty commented 2 years ago

Currently I don't have any idea for now. But I will run code in my system first after checking function I get the idea 👍

Got it! Let me know after your check 👌

MasterCruelty commented 1 year ago

@archetipico do you have any idea to solve?

archetipico commented 1 year ago

I'll look at it as soon as I have free time

MasterCruelty commented 1 year ago

The next issue I'll try to fix is this One as soon as I have an hour or two to spend on it.

MasterCruelty commented 1 year ago

@archetipico Any ideas?

archetipico commented 1 year ago

The last time I wrote here was March 31... I forgot about this issue.

May I suggest that instead of using global k you just pass the variable to the function, like this

def press_button(client, message, k)
    ... # your code without global k

I think the global keyword is initializing k everytime (I may be wrong, but trying isn't harmful)

MasterCruelty commented 1 year ago

The last time I wrote here was March 31... I forgot about this issue.

May I suggest that instead of using global k you just pass the variable to the function, like this

def press_button(client, message, k)
    ... # your code without global k

I think the global keyword is initializing k everytime (I may be wrong, but trying isn't harmful)

If I'm not wrong(it's a bit since my last reiew of that code), that's the problem. If you use global variables it "works" with this issue, but if you use local variables, you can't increment it when you press the button because the new istance has no memory of that variable(it's in the older process, not the current)