robbot icon indicating copy to clipboard operation
robbot copied to clipboard

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

Open MasterCruelty opened this issue 2 years ago • 11 comments

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 avatar Nov 02 '22 22:11 MasterCruelty

Edit: This problem is probably linked with using global variables

MasterCruelty avatar Nov 03 '22 23:11 MasterCruelty

Can i help you in that @MasterCruelty ?

Kd-Here avatar Nov 19 '22 18:11 Kd-Here

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?

MasterCruelty avatar Nov 20 '22 12:11 MasterCruelty

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 👍

Kd-Here avatar Nov 20 '22 16:11 Kd-Here

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 avatar Nov 20 '22 22:11 MasterCruelty

@archetipico do you have any idea to solve?

MasterCruelty avatar Mar 31 '23 17:03 MasterCruelty

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

archetipico avatar Mar 31 '23 17:03 archetipico

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 avatar Sep 04 '23 15:09 MasterCruelty

@archetipico Any ideas?

MasterCruelty avatar Nov 19 '23 12:11 MasterCruelty

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)

archetipico avatar Nov 20 '23 22:11 archetipico

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)

MasterCruelty avatar Nov 20 '23 22:11 MasterCruelty