0
votes

I am having a bit of an issue with a process that goes through all messages in a channel and evaluating them for certain reactions.

I have a loop and it looks for Exclamation Mark, Arrow Left, Red X and Green Tick in that order, as the posts are submissions to get checked by a mod.

for i in msg.reactions:
                   
                if str(i) == ("✅"):
                    status = "Complete"
                    break
                elif str(i) == ("❌"):
                    status = "Complete"
                    break
                elif str(i) == ("⬅️"):
                    status = "Reviewed"
                elif str(i) == ("❗"):
                    status = "Claimed"
                else:
                    status = "Unclaimed"

For whatever reason it absolutely will recognise the exclamation marks, and lists all ones with an exclamation mark as Unclaimed.

I have a feeling this might be the encoding I am using in Notepad++, but I've tried various set ups and can't seem to make it behave differently.

1
Tip: Use the in operator for containers: if str(i) in ("✅", "❌"): status = "Complete" or put it in a dictionary - status = {"✅": "Complete", "❌": "Complete", "⬅️": "Reviewed", "❗": "Claimed"}.get(str(i), "Unclaimed"). You could also use the unicode names for those symbols. - aneroid
I would prefer you should shift to VS Code or PyCharm as these are better IDEs for Python Programming. - Bhavyadeep Yadav

1 Answers

1
votes

It was encoding. Switched from UTF-8 to UTF-8-BOM and now it works.