weidengeist / Willowbot

A chat bot intended to be used on Twitch
GNU General Public License v3.0
4 stars 0 forks source link

Error "needsVIP" : true" #7

Closed LeoAlt8 closed 1 year ago

LeoAlt8 commented 1 year ago

2022-12-03

Error occurs after adding command:

"!!аз" : { "answer" : "Това действие е достъпно само за вас. Така че получавате милион сърца bleedPurple bleedPurple bleedPurple ", "cooldown" : 30, "needsVIP" : true

weidengeist commented 1 year ago

needsVIP expects a boolean value and those have a capital first letter in Python: True, not true. If you use the latter, Python expects it to be a variable and tries to evaluate it, which will fail, because you have not defined true. Depending on your IDE (hopefully, you don’t write Python code in a simple text editor), you should see a difference between true and True in the syntax highlighting of the IDE.

LeoAlt8 commented 1 year ago

Thank you. The description in README.md was just misleading. Please correct the README.md when you have time. ❤️

P.S. You once wrote that you would add support for access to the command by nickname. Is it still topical?

weidengeist commented 1 year ago

Thanks for pointing this out. The typo in the manual has been fixed now.

Additionally, I have implemented the key checks for senderName and senderDisplayName. Those two keys can now be used in the command definitions to limit the usage of command to the specified user(s). This key is a list of users, i. e. even if you want to specify only one user it has to be a list.

commands = {
  '^!hug' : {
    'answer'     : '$senderDisplayName gives $arg0s and $arg1s cat a hug.',
    'matchType'  : 'regex',
    'cooldown'   : 10,
    'senderName' : ['catlover', 'kittygirl', 'meowmeow']
  },

Last but not least I have changed the cyrillicToLatin() routine in such a way that it will only apply when the message contains a mixture of Cyrillic letters and Latin ones so that messages consisting solely of Cyrillic letters will not be affected.

LeoAlt8 commented 1 year ago

Did not work out. I tried both the senderName and the senderDisplayName in the senderName. Nickname copied from the sender's address bar. Nickname without caps. The bot just doesn't respond.

weidengeist commented 1 year ago

Fix has been uploaded. I had two evaluations of the senderName and senderDisplayName in the routine – one for the new name list, one for a string. Looked like I had already implemented that some time ago for strings, forgot about it, implemented it again for lists yesterday, and as both are incompatible with each other, it simply had to fail in any case. m/ Sorry about that.

LeoAlt8 commented 1 year ago

I just tried the update today. Was busy. I want to say it's great! This is a unique feature! I have not met the answer before only by nickname! Thanks!!! ❤️👍

LeoAlt8 commented 1 year ago

Again does not work. The bot answers everyone. VIP and not VIP. 😭

LeoAlt8 commented 1 year ago

@weidengeist , written like this.

"!xxx" : {
    "answer" : "xxxxxxxxx",
    'matchType' : 'startsWith',
    "cooldown"  : 10,
    "needsVIP"  : True
  },
weidengeist commented 1 year ago

I have just uploaded a potential fix. Please test if it works now.

LeoAlt8 commented 1 year ago

Yes. Works. Thank you! 👍❤️