I realize that this is not part of the official PubSub documentation, but it’s possible to listen to multiple channels’ chat_moderator_actions
. towards this end, my software uses this syntax i stole from the live website
ws.send(json.dumps({"type": "LISTEN", "nonce": nonce, "data": {"auth_token": auth_token, "topics": ["chat_moderator_actions.{}.{}".format(my_id, channel_id) for channel_id in channel_ids]}}))
this creates a single listen request with TWO topics; each with a separate channel_id for the two channels i’d like to receive moderator actions for. this works, since the auth_token
grants me permission to listen to each channel’s moderator actions since i’m a moderator in both.
however, there’s an issue with the responses when i execute a moderator command in either of the two channels (or both): the event that is broadcast from, e.g., a ban, can’t be pinned down to one specific channel. in the following example, i’ve banned the user “test” in both channels. upper caps values are anonymized.
{'data': {'type': 'chat_login_moderation', 'moderation_action': 'ban', 'args': ['test', ''], 'created_by': 'MYUSER', 'created_by_user_id': 'MYID', 'msg_id': '', 'target_user_id': '12427', 'target_user_login': '', 'from_automod': False}}
{'data': {'type': 'chat_login_moderation', 'moderation_action': 'ban', 'args': ['test', ''], 'created_by': 'MYUSER', 'created_by_user_id': 'MYID', 'msg_id': '', 'target_user_id': '12427', 'target_user_login': '', 'from_automod': False}}
as you can see, the events appear identical although they are each tied to specific channels. the same issue arises when i get a moderation event from just one channel - i can’t pin down which of the two i’ve got listen requests on it stems.
the obvious workaround to this seems to be to just create a separate connection for each channel with their separate auth_tokens, by-the-book topics and to store in my own code the respective channel names, but that seems very wasteful towards the 10 connections/ip limit.
is this an oversight in the data definition, or am i misunderstanding the intent behind the design of allowing up to 50 topics for one connection?