+ if (!IS_LOCAL(user))
+ return 0;
+
+ if (target_type == TYPE_CHANNEL)
+ {
+ chanrec* c = (chanrec*)dest;
+ if ((c->IsModeSet('M')) && (!user->IsModeSet('r')))
+ {
+ if ((ServerInstance->ULine(user->nick)) || (ServerInstance->ULine(user->server)))
+ {
+ // user is ulined, can speak regardless
+ return 0;
+ }
+ // user messaging a +M channel and is not registered
+ user->WriteServ("477 %s %s :You need a registered nickname to speak on this channel", user->nick, c->name);
+ return 1;
+ }
+ }
+ if (target_type == TYPE_USER)
+ {
+ userrec* u = (userrec*)dest;
+ if ((u->IsModeSet('R')) && (!user->IsModeSet('r')))
+ {
+ if ((ServerInstance->ULine(user->nick)) || (ServerInstance->ULine(user->server)))
+ {
+ // user is ulined, can speak regardless
+ return 0;
+ }
+ // user messaging a +R user and is not registered
+ user->WriteServ("477 %s %s :You need a registered nickname to message this user", user->nick, u->nick);
+ return 1;
+ }
+ }
+ return 0;
+ }
+
+ virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
+ {
+ return OnUserPreMessage(user,dest,target_type,text,status, exempt_list);
+ }
+
+ virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs)
+ {
+ if (chan)
+ {
+ if (chan->IsModeSet('R'))
+ {
+ if (!user->IsModeSet('r'))
+ {
+ if ((ServerInstance->ULine(user->nick)) || (ServerInstance->ULine(user->server)))
+ {
+ // user is ulined, won't be stopped from joining
+ return 0;
+ }
+ // joining a +R channel and not identified
+ user->WriteServ("477 %s %s :You need a registered nickname to join this channel", user->nick, chan->name);
+ return 1;
+ }
+ }
+ }
+ return 0;