@@ -117,14 +117,17 @@ async def send_to_discord(cls, updated_json, endpoint, attachments: list = None)
117117 try :
118118 read_discord = await read_handler .ReadHandler .check_read (endpoint , "discord" )
119119 if read_discord is False :
120- if updated_json ["meta" ]["sender-channel" ] in updated_json ["config" ]["channels" ]["guilded" ]:
121- webhook = updated_json ["config" ]["webhooks" ]["discord" ][updated_json ["config" ]["channels" ]["guilded" ].index (updated_json ["meta" ]["sender-channel" ])]
122- elif updated_json ["meta" ]["sender-channel" ] in updated_json ["config" ]["channels" ]["nerimity" ]:
123- webhook = updated_json ["config" ]["webhooks" ]["discord" ][updated_json ["config" ]["channels" ]["nerimity" ].index (updated_json ["meta" ]["sender-channel" ])]
124- elif updated_json ["meta" ]["sender-channel" ] in updated_json ["config" ]["channels" ]["revolt" ]:
125- webhook = updated_json ["config" ]["webhooks" ]["discord" ][updated_json ["config" ]["channels" ]["revolt" ].index (updated_json ["meta" ]["sender-channel" ])]
126- else :
127- raise errors .SendingError .ChannelNotFound (f'The channel { updated_json ["meta" ]["sender-channel" ]} ({ updated_json ["meta" ]["sender" ]} ) does not seem to be a registered channel on other platforms.' )
120+ try :
121+ if updated_json ["meta" ]["sender-channel" ] in updated_json ["config" ]["channels" ]["guilded" ]:
122+ webhook = updated_json ["config" ]["webhooks" ]["discord" ][updated_json ["config" ]["channels" ]["guilded" ].index (updated_json ["meta" ]["sender-channel" ])]
123+ elif updated_json ["meta" ]["sender-channel" ] in updated_json ["config" ]["channels" ]["nerimity" ]:
124+ webhook = updated_json ["config" ]["webhooks" ]["discord" ][updated_json ["config" ]["channels" ]["nerimity" ].index (updated_json ["meta" ]["sender-channel" ])]
125+ elif updated_json ["meta" ]["sender-channel" ] in updated_json ["config" ]["channels" ]["revolt" ]:
126+ webhook = updated_json ["config" ]["webhooks" ]["discord" ][updated_json ["config" ]["channels" ]["revolt" ].index (updated_json ["meta" ]["sender-channel" ])]
127+ else :
128+ raise errors .SendingError .ChannelNotFound (f'The channel { updated_json ["meta" ]["sender-channel" ]} ({ updated_json ["meta" ]["sender" ]} ) does not seem to be a registered channel on other platforms.' )
129+ except KeyError :
130+ return True
128131 nextcord_files = []
129132 if attachments is not None :
130133 for attachment in attachments :
@@ -164,14 +167,17 @@ async def send_to_guilded(cls, updated_json, endpoint, attachments: list = None)
164167 try :
165168 read_guilded = await read_handler .ReadHandler .check_read (endpoint , "guilded" )
166169 if read_guilded is False :
167- if updated_json ["meta" ]["sender-channel" ] in updated_json ["config" ]["channels" ]["discord" ]:
168- webhook = updated_json ["config" ]["webhooks" ]["guilded" ][updated_json ["config" ]["channels" ]["discord" ].index (updated_json ["meta" ]["sender-channel" ])]
169- elif updated_json ["meta" ]["sender-channel" ] in updated_json ["config" ]["channels" ]["nerimity" ]:
170- webhook = updated_json ["config" ]["webhooks" ]["guilded" ][updated_json ["config" ]["channels" ]["nerimity" ].index (updated_json ["meta" ]["sender-channel" ])]
171- elif updated_json ["meta" ]["sender-channel" ] in updated_json ["config" ]["channels" ]["revolt" ]:
172- webhook = updated_json ["config" ]["webhooks" ]["guilded" ][updated_json ["config" ]["channels" ]["revolt" ].index (updated_json ["meta" ]["sender-channel" ])]
173- else :
174- raise errors .SendingError .ChannelNotFound (f'The channel { updated_json ["meta" ]["sender-channel" ]} ({ updated_json ["meta" ]["sender" ]} ) does not seem to be a registered channel on other platforms.' )
170+ try :
171+ if updated_json ["meta" ]["sender-channel" ] in updated_json ["config" ]["channels" ]["discord" ]:
172+ webhook = updated_json ["config" ]["webhooks" ]["guilded" ][updated_json ["config" ]["channels" ]["discord" ].index (updated_json ["meta" ]["sender-channel" ])]
173+ elif updated_json ["meta" ]["sender-channel" ] in updated_json ["config" ]["channels" ]["nerimity" ]:
174+ webhook = updated_json ["config" ]["webhooks" ]["guilded" ][updated_json ["config" ]["channels" ]["nerimity" ].index (updated_json ["meta" ]["sender-channel" ])]
175+ elif updated_json ["meta" ]["sender-channel" ] in updated_json ["config" ]["channels" ]["revolt" ]:
176+ webhook = updated_json ["config" ]["webhooks" ]["guilded" ][updated_json ["config" ]["channels" ]["revolt" ].index (updated_json ["meta" ]["sender-channel" ])]
177+ else :
178+ raise errors .SendingError .ChannelNotFound (f'The channel { updated_json ["meta" ]["sender-channel" ]} ({ updated_json ["meta" ]["sender" ]} ) does not seem to be a registered channel on other platforms.' )
179+ except KeyError :
180+ return True
175181 guilded_files = []
176182 if attachments is not None :
177183 for attachment in attachments :
@@ -221,14 +227,17 @@ async def send_to_nerimity(cls, updated_json, endpoint, attachments: list = None
221227 response_json = updated_json
222228 sender_channel = response_json ["meta" ]["sender-channel" ]
223229 discord_channels = response_json ["config" ]["channels" ]["discord" ]
224- if sender_channel in discord_channels :
225- channel_id = response_json ["config" ]["channels" ]["nerimity" ][discord_channels .index (sender_channel )]
226- elif sender_channel in response_json ["config" ]["channels" ]["guilded" ]:
227- channel_id = response_json ["config" ]["channels" ]["nerimity" ][response_json ["config" ]["channels" ]["guilded" ].index (sender_channel )]
228- elif sender_channel in response_json ["config" ]["channels" ]["revolt" ]:
229- channel_id = response_json ["config" ]["channels" ]["nerimity" ][response_json ["config" ]["channels" ]["revolt" ].index (sender_channel )]
230- else :
231- raise errors .SendingError .ChannelNotFound (f'The channel { sender_channel } ({ updated_json ["meta" ]["sender" ]} ) does not seem to be a registered channel on other platforms.' )
230+ try :
231+ if sender_channel in discord_channels :
232+ channel_id = response_json ["config" ]["channels" ]["nerimity" ][discord_channels .index (sender_channel )]
233+ elif sender_channel in response_json ["config" ]["channels" ]["guilded" ]:
234+ channel_id = response_json ["config" ]["channels" ]["nerimity" ][response_json ["config" ]["channels" ]["guilded" ].index (sender_channel )]
235+ elif sender_channel in response_json ["config" ]["channels" ]["revolt" ]:
236+ channel_id = response_json ["config" ]["channels" ]["nerimity" ][response_json ["config" ]["channels" ]["revolt" ].index (sender_channel )]
237+ else :
238+ raise errors .SendingError .ChannelNotFound (f'The channel { sender_channel } ({ updated_json ["meta" ]["sender" ]} ) does not seem to be a registered channel on other platforms.' )
239+ except KeyError :
240+ return True
232241 message_author_name = response_json ["meta" ]["message" ]["author" ]["name" ]
233242 message_content = response_json ["meta" ]["message" ]["content" ]
234243 message_content = await emoji_handler .convert_message (message_content , updated_json ["meta" ]["sender" ], "nerimity" , endpoint )
@@ -290,15 +299,17 @@ async def send_to_nerimity(cls, updated_json, endpoint, attachments: list = None
290299 @classmethod
291300 async def send_to_revolt (cls , updated_json , endpoint , attachments : list = None ):
292301 if updated_json ["meta" ]["read" ]["revolt" ] is False :
293- if updated_json ["meta" ]["sender-channel" ] in updated_json ["config" ]["channels" ]["discord" ]:
294- channel_id = updated_json ["config" ]["channels" ]["revolt" ][updated_json ["config" ]["channels" ]["discord" ].index (updated_json ["meta" ]["sender-channel" ])]
295- elif updated_json ["meta" ]["sender-channel" ] in updated_json ["config" ]["channels" ]["guilded" ]:
296- channel_id = updated_json ["config" ]["channels" ]["revolt" ][updated_json ["config" ]["channels" ]["guilded" ].index (updated_json ["meta" ]["sender-channel" ])]
297- elif updated_json ["meta" ]["sender-channel" ] in updated_json ["config" ]["channels" ]["nerimity" ]:
298- channel_id = updated_json ["config" ]["channels" ]["revolt" ][updated_json ["config" ]["channels" ]["nerimity" ].index (updated_json ["meta" ]["sender-channel" ])]
299- else :
300- raise errors .SendingError .ChannelNotFound (f"The channel { updated_json ["meta" ]["sender-channel" ]} ({ updated_json ["meta" ]["sender" ]} ) does not seem to be a registered channel on other platforms." )
301-
302+ try :
303+ if updated_json ["meta" ]["sender-channel" ] in updated_json ["config" ]["channels" ]["discord" ]:
304+ channel_id = updated_json ["config" ]["channels" ]["revolt" ][updated_json ["config" ]["channels" ]["discord" ].index (updated_json ["meta" ]["sender-channel" ])]
305+ elif updated_json ["meta" ]["sender-channel" ] in updated_json ["config" ]["channels" ]["guilded" ]:
306+ channel_id = updated_json ["config" ]["channels" ]["revolt" ][updated_json ["config" ]["channels" ]["guilded" ].index (updated_json ["meta" ]["sender-channel" ])]
307+ elif updated_json ["meta" ]["sender-channel" ] in updated_json ["config" ]["channels" ]["nerimity" ]:
308+ channel_id = updated_json ["config" ]["channels" ]["revolt" ][updated_json ["config" ]["channels" ]["nerimity" ].index (updated_json ["meta" ]["sender-channel" ])]
309+ else :
310+ raise errors .SendingError .ChannelNotFound (f"The channel { updated_json ["meta" ]["sender-channel" ]} ({ updated_json ["meta" ]["sender" ]} ) does not seem to be a registered channel on other platforms." )
311+ except KeyError :
312+ return True
302313 headers = {
303314 "X-Bot-Token" : f"{ config .REVOLT_TOKEN } "
304315 }
0 commit comments