FBChatBot / app /channel_manager.py
VietCat's picture
refactor chat channel structure
f6cdf9d
raw
history blame contribute delete
456 Bytes
from app.chat_channel import ChatChannel
class ChannelManager:
def __init__(self):
self.channels = {} # {(channel_type, page_id): ChatChannel}
def get_or_create_channel(self, channel_type: str, page_id: str) -> ChatChannel:
key = (channel_type, page_id)
if key not in self.channels:
self.channels[key] = ChatChannel(page_id, channel_type)
return self.channels[key]
channel_manager = ChannelManager()