fbchat-dev / fbchat

Facebook Chat (Messenger) for Python
https://fbchat.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.19k stars 412 forks source link

Custom colors #185

Closed tlaskyd closed 7 years ago

tlaskyd commented 7 years ago

Hello. In my messenger I have my own custom colors (such as # 000000), so there is a problem with enumeration. It would be great to make a better way to represent colors than Enum.

madsmtm commented 7 years ago

This seems illogical, since Facebook either throws an error, or just ignores the request, if the color was invalid. If you absolutely want to do this, you can overwrite the ThreadColor enum like this:

import fbchat

class Color(object):
    def __init__(self, color=''):
        self.value = color

fbchat.models.ThreadColor = Color

And then you can use it like this:

client.changeThreadColor(fbchat.models.ThreadColor('#000000'), '<thread_id>')