Esempio n. 1
0
 def send_topic_to_user(self,user):
     if self.is_invisible and user not in self.users:
         return
     if self.topic is None:
         user.send_num(331,'%s :No topic is set'%self.name)
         return
     user.send_num(332 ,'%s :%s'%(self.name,self.topic))
Esempio n. 2
0
 def send_welcome(self,user):
     if not user.nick.endswith('.onion'):
         user.send_num('001','HOLY CRAP CONNECTED')
         #user.send_num('002','Your host is %s, running version nameless-ircd'%self.name)
         #user.send_num('003','This server was created a while ago')
         #user.send_num('004','%s nameless-ircd x m'%self.name)
     self.send_motd(user)
     if hasattr(user,'after_motd') and user.after_motd is not None:
         user.after_motd()
     if user.nick.endswith('.onion'):
         return
     user.welcomed = True
Esempio n. 3
0
 def change_nick(self,user,newnick):
     self.dbg('server nick change %s -> %s' % (user.nick,newnick))
     if len(newnick) > 30:
         user.send_num(432, "%s :Erroneous nickname"%newnick)
         newnick = user.do_nickname('')
     elif newnick in self.users:
         user.send_num(433, "%s :Nickname is already in use"%newnick)
         if newnick == user.nick: return
         newnick = user.do_nickname('')
     self.users[user.nick] = user #FIXME: this isn't necessary...is it?
     self.users[newnick] = self.users.pop(user.nick)
     user.nick_change(user,newnick)
     for chan in user.chans:
         self.dbg('inform %s of nick change'%chan)
         if chan in self.chans:
             self.chans[chan].nick_change(user,newnick)
     user.nick = newnick
     user.usr = newnick
     self.dbg('user is now %s'%user)
Esempio n. 4
0
 def privmsg(self,user,dest,msg):
     msg = msg[1:]
     onion = user.nick.endswith('.onion')
     self.dbg('privmsg %s -> %s -- %s'%(user.nick,dest,msg))
     if (dest[0] in ['&','#'] and not self._has_channel(dest)) or (dest[0] not in ['&','#'] and not self.has_nick(str(user))):
         user.send_num(401,'% :No such nick/channel'%dest)
         return
     if dest.endswith('serv'):
         dest = dest.lower().split('serv')[0]
         if not self.has_service(dest):
             user.privmsg(dest,'no such service')
             return
         self.service[dest].serve(self,user,msg)
         return 
     if dest[0] in ['#','&']:
         dest =  dest.lower()
         if dest in user.chans:
             self.chans[dest].privmsg(user,msg)
     else:
         if dest in self.users:
             self.users[dest].privmsg(user,msg)
Esempio n. 5
0
 def send_list(self,user):
     user.send_num(321,'Channel :Users  Name')
     for chan in self.chans:
         chan = self.chans[chan]
         if chan.is_invisible():
             continue
         user.send_num(322,'%s %d :%s'%(chan.name,len(chan),chan.topic or ''))
     user.send_num(323 ,':End of LIST')
Esempio n. 6
0
 def change_nick(self,user,newnick):
     self.dbg('server nick change %s -> %s' % (user.nick,newnick))
     if len(newnick) > 30:
         user.send_num(432, "%s :Erroneous nickname"%newnick)
         newnick = user.do_nickname('')
     elif newnick in self.users:
         user.send_num(433, "%s :Nickname is already in use"%newnick)
         if newnick == user.nick: return
         newnick = user.do_nickname('')
     self.users[user.nick] = user #FIXME: this isn't necessary...is it?
     self.users[newnick] = self.users.pop(user.nick)
     for u in self.users.values():
         if not isinstance(u, User): continue
         if u == user: continue
         print u.nick, user.chans, u.chans
         for chan in set(user.chans).intersection(u.chans):
             print chan, self.chans[chan].is_anon()
             if not self.chans[chan].is_anon():
                 u.nick_change(user,newnick)
                 break
     user.nick_change(user,newnick)
     user.nick = newnick
     user.usr = newnick
     self.dbg('user is now %s'%user)
Esempio n. 7
0
    def send_who(self,user):

        if self.is_anon():
            user.send_num(353,'= %s :%s anonymous'%(self.name,user.nick))
        else:
            nicks = ''
            for u in self.users:
                nicks += ' ' + u.nick    
            user.send_num(353,'= %s :%s'%( self.name,nicks.strip()))
        user.send_num(366,'%s :End of NAMES list'%self.name)
Esempio n. 8
0
 def send_who(self,user):
     mod = '='  or ( self.is_invisible and '@' ) or (self.name[0] == '&' and '*' )
     if self.is_anon():
         user.send_num(353,'%s %s :%s anonymous'%(mod,self.name,user.nick))
     else:
         nicks = ''
         for u in self.users:
             nicks += ' ' + u.nick    
         user.send_num(353,'%s %s :%s'%(mod, self.name,nicks.strip()))
     user.send_num(366,'%s :End of NAMES list'%self.name)
Esempio n. 9
0
 def _send_topic_to_user(self,user):
     if self.topic is None:
         user.send_num(331,':No topic is set')
         return
     user.send_num(332 ,':%s'%self.topic)
Esempio n. 10
0
 def send_motd(self,user):
     user.send_num(375,':- %s Message of the day -'%self.name)
     for line in self.motd().split('\n'):
         user.send_num(372, ':- %s '%line)
     user.send_num(376, ':- End of MOTD command')
Esempio n. 11
0
 def set_topic(self,user,topic):
     if user not in self.users:
         user.send_num(442, "%s :You're not on that channel"%self.name)
         return
     self.topic = topic
     self.send_topic()