- user->WriteServ("470 %s :%s has become full, so you are automatically being transferred to the linked channel %s",user->nick,cname,channel.c_str());
- chanrec::JoinUser(user, channel.c_str(), false);
- return 1;
+
+ /* sometimes broken ulines can make circular or chained +L, avoid this */
+ Channel* destchan = NULL;
+ destchan = ServerInstance->FindChan(channel);
+ if (destchan && destchan->IsModeSet('L'))
+ {
+ user->WriteNumeric(470, "%s %s * :You may not join this channel. A redirect is set, but you may not be redirected as it is a circular loop.", user->nick.c_str(), cname.c_str());
+ return MOD_RES_DENY;
+ }
+ /* We check the bool value here to make sure we have it enabled, if we don't then
+ usermode +L might be assigned to something else. */
+ if (UseUsermode && user->IsModeSet('L'))
+ {
+ user->WriteNumeric(470, "%s %s %s :Force redirection stopped.", user->nick.c_str(), cname.c_str(), channel.c_str());
+ return MOD_RES_DENY;
+ }
+ else
+ {
+ user->WriteNumeric(470, "%s %s %s :You may not join this channel, so you are automatically being transferred to the redirect channel.", user->nick.c_str(), cname.c_str(), channel.c_str());
+ Channel::JoinUser(user, channel, false, "", false, ServerInstance->Time());
+ return MOD_RES_DENY;
+ }