def handle_member_join(request, event, destination): cdata = ChannelManager.get_channel_token( Platform.LINE, LineApiUtils.get_channel_id(event), auto_register=True) joined_names = [] for user in event.joined.members: uid = user.user_id udata_result = RootUserManager.get_root_data_onplat(Platform.LINE, uid) if udata_result.success and cdata: ProfileManager.register_new_default_async(cdata.id, udata_result.model.id) uname = RootUserManager.get_root_data_uname( udata_result.model.get_oid(), cdata).user_name if uname: joined_names.append(uname) LINE.temp_apply_format(event_dest_fmt, logging.INFO, "LINE Join Group.", extra={ ExtraKey.Event: event, ExtraKey.Destination: destination }) LineApiWrapper.reply_text( event.reply_token, _("{} joined the group.").format(" & ".join(joined_names)))
async def on_member_join(self, member: Member): udata_result = RootUserManager.get_root_data_onplat(Platform.DISCORD, member.id, auto_register=True) cdata = ChannelManager.get_channel_token(Platform.DISCORD, member.guild.id, auto_register=True) if udata_result.success and cdata: ProfileManager.register_new_default_async(cdata.id, udata_result.model.id) sys_channel = member.guild.system_channel if sys_channel: await sys_channel.send(_("{} joined the server.").format(member.mention))
def handle_message_main(e: MessageEventObject) -> HandledMessageEventsHolder: try: if e.user_model: # Ensure User existence in channel ProfileManager.register_new_default_async(e.channel_model.id, e.user_model.id) # Translation activation activate(e.user_model.config.language) else: # User model could be `None` if user token is not provided. This happens on LINE. # Notify users when they attempted to use any features related of the Jelly Bot from .spec.no_utoken import handle_no_user_token return HandledMessageEventsHolder(e.channel_model, handle_no_user_token(e)) # Main handle process event_type = type(e) if event_type in fn_box: ret = HandledMessageEventsHolder(e.channel_model, fn_box[event_type](e)) else: logger.logger.info( f"Message handle object not handled. Raw: {e.raw}") ret = HandledMessageEventsHolder(e.channel_model) # Translation deactivation deactivate() # Record message for stats / User model could be `None` on LINE if e.user_model: MessageRecordStatisticsManager.record_message_async( e.channel_model.id, e.user_model.id, e.message_type, e.content, e.constructed_time) return ret except Exception as ex: from .spec.error import handle_error_main return HandledMessageEventsHolder(e.channel_model, handle_error_main(e, ex))