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
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)
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
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)
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)
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()
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()
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)
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 }
def set_mode(self, mode, value=None): if mode == 'a': self.admindict[value] = 1 else: Channel.set_mode(self, mode, value)
def change_nick(self, before, after): Channel.change_nick(self, before, after) self.logdict[after] = self.logdict[before] del self.logdict[before]
def clear_mode(self, mode, value=None): if mode == 'a': del self.admindict[value] else: Channel.clear_mode(self, mode, value)
def add_user(self, nick): self.logdict[nick] = tempfile.NamedTemporaryFile(bufsize=5120) Channel.add_user(self, nick)
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)