示例#1
0
文件: fafbot.py 项目: fafafaf/server
 def _on_join(self, c, e):
     try:
         ch = e.target
         nick = e.source.nick
         if nick == c.get_nickname():
             self.channels[ch] = Channel()
             self.connection.send_raw("NAMES" + (ch))
             #self.connection.send_raw("PRIVMSG %s :%s" % ("#aeolus", "yo!"))
         elif "aeolus" in ch :
             #print nick,"has joined", ch
             query = QtSql.QSqlQuery(self.db)
             query.prepare("SELECT faction, IFNULL(dominant,-1) FROM galacticwar.accounts LEFT join galacticwar.domination on galacticwar.accounts.faction = galacticwar.domination.slave WHERE  galacticwar.accounts.uid = (SELECT id FROM faf_lobby.login WHERE login = ? )")
             query.addBindValue(nick)
             query.exec_()
             if query.size() > 0:
                 query.first()
                 if int(query.value(1)) != -1:
                     faction = int(query.value(1))
                 else:
                     faction = int(query.value(0))
                 if faction == 0 :
                     channel = "#UEF"
                 elif faction == 1 :
                     channel = "#Aeon"
                 elif faction == 2 :
                     channel = "#Cybran"
                 elif faction == 3 :
                     channel = "#Seraphim"
 
                 self.connection.privmsg('chanserv', 'INVITE %s %s' % (channel, nick))
         self.channels[ch].add_user(nick)
     except:
         pass
示例#2
0
 def on_join(self, c, e):
     ch = e.target
     nick = e.source.nick
     if nick == c.get_nickname():
         self.channels[ch] = Channel()
     self.channels[ch].add_user(nick)
     lg.debug('IRCChatBot::on_join: %s =====>>> %s', nick, ch)
示例#3
0
    def test_is_oper(self):
        tmp = IRCWrapper(nullLogger)
        tmp.channels["#tmp"] = Channel()
        tmp.channels["#tmp"].operdict["foobar"] = True

        assert tmp.is_oper("#tmp", "foobar") is True
        assert tmp.is_oper("#tmp", "quux") is False
示例#4
0
 def __init__(self, namreply=None):
   Channel.__init__(self)
   self.admindict = IRCDict()
   self.logdict = IRCDict()
   if namreply:
     for nick in namreply.split(' '):
       if nick[0] == '~': self.ownerdict[nick[1:]] = 1
       elif nick[0] == '&': self.admindict[nick[1:]] = 1
       elif nick[0] == '@': self.operdict[nick[1:]] = 1
       elif nick[0] =='%': self.halfopdict[nick[1:]] = 1
       elif nick[0] == '+': self.voicedict[nick[1:]] = 1
       else: 
         self.userdict[nick] = 1
         self.logdict[nick] = tempfile.NamedTemporaryFile(bufsize=5120)
         continue
       self.userdict[nick[1:]] = 1
       self.logdict[nick[1:]] = tempfile.NamedTemporaryFile(bufsize=5120)
示例#5
0
文件: irc.py 项目: danhetrick/qbit
    def join_channel(self, sender, **kw):
        channel = kw['channel']
        nick = kw['nick']
        hostmask = kw['hostmask']

        if nick == self.nickname:
            self.channels[channel] = Channel()
            self.clientjoined.emit(channel)
        else:
            pm = [channel, nick, hostmask]
            self.joined.emit(pm)
示例#6
0
 def channel_joiner(self, serv):
     join_count = 0
     join_limit = 5
     while not self.channel_join_queue.empty() and join_count < join_limit:
         channel = self.channel_join_queue.get()
         self.channels[channel] = Channel()
         self.channel_list.append(channel)
         serv.join(channel)
         logging.info("[%s] Joining channel %s", self.worker_name, channel)
         join_count += 1
     threading.Timer(1.5, self.channel_joiner, args=(serv, )).start()
示例#7
0
 def channel_joiner(self, serv):
     join_count = 0
     join_limit = 1
     while not self.channel_join_queue.empty() and join_count < join_limit:
         if self.is_connected:
             channel = self.channel_join_queue.get()
             self.channels[channel] = Channel()
             self.channel_list.append(channel)
             serv.join(channel)
             self.log("Joining channel %s" % channel)
             join_count += 1
     threading.Timer(1.5, self.channel_joiner, args=(serv, )).start()
示例#8
0
 def __init__(self, namreply=None):
     Channel.__init__(self)
     self.admindict = IRCDict()
     self.logdict = IRCDict()
     if namreply:
         for nick in namreply.split(' '):
             if nick[0] == '~':
                 self.ownerdict[nick[1:]] = 1
             elif nick[0] == '&':
                 self.admindict[nick[1:]] = 1
             elif nick[0] == '@':
                 self.operdict[nick[1:]] = 1
             elif nick[0] == '%':
                 self.halfopdict[nick[1:]] = 1
             elif nick[0] == '+':
                 self.voicedict[nick[1:]] = 1
             else:
                 self.userdict[nick] = 1
                 self.logdict[nick] = tempfile.NamedTemporaryFile(bufsize=5120)
                 continue
             self.userdict[nick[1:]] = 1
             self.logdict[nick[1:]] = tempfile.NamedTemporaryFile(bufsize=5120)
示例#9
0
    def __init__(self, ircbot, name):
        """
        Create a new IRCChannel instance.
        :param ircbot: The IRC BOT object instance.
        :param name: The channel name.
        """
        Channel.__init__(self)

        self.ircbot = ircbot
        self.plugin = ircbot.plugin
        self.connection = ircbot.connection
        self.name = name

        # this will overwrite the modes attribute set
        # in the Channel constructor: was a dict but we
        # don't need to associate keys to values
        self.modes = []

        self.modedict = {
            'o': self.operdict,
            'v': self.voiceddict,
            'q': self.ownerdict,
            'h': self.halfopdict
        }
示例#10
0
 def set_mode(self, mode, value=None):
     if mode == 'a':
         self.admindict[value] = 1
     else:
         Channel.set_mode(self, mode, value)
示例#11
0
 def change_nick(self, before, after):
     Channel.change_nick(self, before, after)
     self.logdict[after] = self.logdict[before]
     del self.logdict[before]
示例#12
0
 def clear_mode(self, mode, value=None):
     if mode == 'a':
         del self.admindict[value]
     else:
         Channel.clear_mode(self, mode, value)
示例#13
0
 def add_user(self, nick):
     self.logdict[nick] = tempfile.NamedTemporaryFile(bufsize=5120)
     Channel.add_user(self, nick)
示例#14
0
 def add_user(self, nick):
   self.logdict[nick] = tempfile.NamedTemporaryFile(bufsize=5120)
   Channel.add_user(self, nick)
示例#15
0
文件: ircclient.py 项目: yerejm/ttt
 def _on_join(self, c, e):
     ch = e.target
     nick = e.source.nick
     if nick == c.get_nickname():
         self.channels[ch] = Channel()
     self.channels[ch].add_user(nick)
示例#16
0
 def clear_mode(self, mode, value=None):
   if mode == 'a':
     del self.admindict[value]
   else:
     Channel.clear_mode(self, mode, value)
示例#17
0
 def set_mode(self, mode, value=None):
   if mode == 'a':
     self.admindict[value] = 1
   else:
     Channel.set_mode(self, mode, value)
示例#18
0
 def change_nick(self, before, after):
   Channel.change_nick(self, before, after)
   self.logdict[after] = self.logdict[before]
   del self.logdict[before]