def on_privmsg_or_notice(self, event, sock, source, target, message): user = User.objects.filter(sock=sock).first() prefix = user.prefix or joinprefix(*source) if target.startswith(u"#"): channel = Channel.objects.filter(name=target).first() if channel is None: return ERR_NOSUCHCHANNEL(target) if "n" in channel.modes: if not user.oper and user not in channel.users: return ERR_CANNOTSENDTOCHAN(channel.name) if "m" in channel.modes: if not user.oper and user not in chain(channel.operators, channel.voiced): return ERR_CANNOTSENDTOCHAN(channel.name) self.notify(channel.users, _Message(u"PRIVMSG", target, message, prefix=prefix), user) else: user = User.objects.filter(nick=target).first() if user is None: return ERR_NOSUCHNICK(target) return reply( user.sock, _Message(event.name.upper(), target, message, prefix=prefix))
def on_privmsg_or_notice(self, event, sock, source, target, message): user = User.objects.filter(sock=sock).first() prefix = user.prefix or joinprefix(*source) if target and target[0] in (u("&"), u("#"),): channel = Channel.objects.filter(name=target).first() if channel is None: return ERR_NOSUCHCHANNEL(target) if u("n") in channel.modes: if not user.oper and user not in channel.users: return ERR_CANNOTSENDTOCHAN(channel.name) if u("m") in channel.modes: if not user.oper and user not in chain(channel.operators, channel.voiced): return ERR_CANNOTSENDTOCHAN(channel.name) self.notify( channel.users, _Message(u("PRIVMSG"), target, message, prefix=prefix), user ) else: user = User.objects.filter(nick=target).first() if user is None: return ERR_NOSUCHNICK(target) return reply( user.sock, _Message( event.name.upper(), target, message, prefix=prefix ) )
def _user_message(self, event, sock, source, target, message): user = User.objects.filter(sock=sock).first() user.lastmessage = int(time()) user.save() nick = User.objects.filter(nick=target).first() if nick is None: return ERR_NOSUCHNICK(target) self.fire( reply( nick.sock, _Message(event.name.upper(), nick.nick, message, prefix=user.prefix) ), "server" ) if nick.away: return RPL_AWAY(nick.nick, nick.away)
def _channel_message(self, event, sock, source, target, message): user = User.objects.filter(sock=sock).first() user.lastmessage = int(time()) user.save() channel = Channel.objects.filter(name=target).first() if channel is None: return ERR_NOSUCHCHANNEL(target) if u("n") in channel.modes: if not user.oper and user not in channel.users: return ERR_CANNOTSENDTOCHAN(channel.name) if u("m") in channel.modes: if not user.oper and user not in chain(channel.operators, channel.voiced): return ERR_CANNOTSENDTOCHAN(channel.name) self.notify( channel.users, _Message(event.name.upper(), target, message, prefix=user.prefix), user )