Kick someone from a channel.
        Required arguments:
        * channel - Channel to kick them from.
        * nick - Nick to kick.
        Optional arguments:
        * reason - Reason for the kick.
427614
def kick(self, channel, nick, reason=''):
        
        with self.lock:
            self.is_in_channel(channel)

            self.send('KICK %s %s :%s' % (channel, nick, reason))

            if self.readable():
                msg = self._recv(expected_replies=('KICK',))

                if msg[0] == 'KICK':
                    channel = msg[1]
                    if not self.hide_called_events:
                        self.stepback()

            if self.compare(self.current_nick, nick):
                del self.channels[channel]
56821
def _nick(self, nick):
        
        with self.lock:
            self.send('NICK :%s' % nick)

            if self.readable():
                msg = self._recv(expected_replies='NICK')
                if msg[0] == 'NICK':
                    if not self.hide_called_events:
                        self.stepback()

            for channel in self.channels:
                if 'USERS' in self.channels[channel]:
                    priv_level = \
                    self.channels[channel]['USERS'][self.current_nick]
                    del self.channels[channel]['USERS'][self.current_nick]
                    self.channels[channel]['USERS'][nick] = priv_level
            self.current_nick = nick
1236833
def _raise_closed(reason):
        """"""
        if isinstance(reason, Message):
            if reason.method.klass.name == "channel":
                raise ChannelClosed(reason)
            elif reason.method.klass.name == "connection":
                raise ConnectionClosed(reason)
        raise Closed(reason)
493094
def quit(self):
        
        
        for c in self.channels:
            c.users.remove(self.nick)
        self.channels = []
815381
def part(self, channel, reason=''):
        
        with self.lock:
            self.is_in_channel(channel)

            self.send('PART %s :%s' % (channel, reason))
            msg = self._recv(expected_replies=('PART',))
            if msg[0] == 'PART':
                del self.channels[msg[1]]
                if not self.hide_called_events:
                    self.stepback()
1243979
def cmd(send, msg, args):
    
    parser = arguments.ArgParser(args['config'])
    parser.add_argument('--channel', action=arguments.ChanParser)
    parser.add_argument('nick', nargs='*')
    try:
        cmdargs = parser.parse_args(msg)
    except arguments.ArgumentException as e:
        send(str(e))
        return
    quote = args['db'].query(Log.msg, Log.source)
    nick = ' '.join(cmdargs.nick) if cmdargs.nick else ""
    if nick:
        quote = quote.filter(Log.source == nick)
    else:
        quote = quote.filter(Log.source != args['botnick'])
    target = cmdargs.channels[0] if hasattr(cmdargs, 'channels') else args['config']['core']['channel']
    quote = quote.filter(or_(Log.type == 'pubmsg', Log.type == 'privmsg', Log.type == 'action'), Log.target == target,
                         func.length(Log.msg) > 5).order_by(func.random()).first()
    if quote:
        send("%s -- %s" % quote)
    elif nick:
        send("%s isn't very quotable." % nick)
    else:
        send("Nobody is very quotable :(")
1320757
def unsubscribe(self, *args):
        
        if args:
            args = list_or_args(args[0], args[1:])
            channels = self._normalize_keys(dict.fromkeys(args))
        else:
            channels = self.channels
        self.pending_unsubscribe_channels.update(channels)
        return self.execute_command('UNSUBSCRIBE', *args)
1295512
def onExit(self):
        
        def try_call(fn):
            try:
                fn()
            except (pika.exceptions.ChannelClosed, AttributeError,
                    pika.exceptions.ConnectionClosed):
                return

        if hasattr(self, "channel"):
            try_call(self.channel.cancel)
            try_call(self.channel.close)
            try_call(self.connection.close)
117011
function(channel, fn, context){
      if (!channels[channel]) return;

      var subscription;
      for (var i = 0; i < channels[channel].length; i++) {
        subscription = channels[channel][i];
        if (subscription.fn === fn && subscription.context === context) {
          channels[channel].splice(i, 1);
          i--;
        }
      }
    }
823667
def do_close(self, reason):
        """"""
        if self.closed:
            return
        self.closed = True
        self.reason = reason
        self.incoming.close()
        self.responses.close()
        if not self._closing:
            self.client.channel_failed(self, Failure(reason))
774930
def remove(channel_or_channel_name)
      @mutex.synchronize do
        if channel_or_channel_name.is_a?(String)
          channel_or_channel_name = find(channel_or_channel_name)
        end
 
        @channels.delete(channel_or_channel_name)
      end
    end
325775
def add_user(self, user):
        """"""
        if not isinstance(user, User):
            user = User(user)
        if user.nick in self.members:
            _log.warning("Ignoring request to add user '%s' to channel '%s' "
                         "because that user is already in the member list.",
                         user, self.name)
            return
        self.members[user.nick] = user
        _log.debug("Added '%s' to channel '%s'", user, self.name)
340581
def finish(request, socket, context):
    
    try:
        user = context["user"]
    except KeyError:
        return
    left = {"action": "leave", "name": user.name, "id": user.id}
    socket.broadcast_channel(left)
    user.delete()
1074660
function (self, cmd, channel, cb) {
		if (typeof(cb) != "function") {
			cb = false;
		}

		if (typeof(channel) == "number") {
			channel = channel.toString();
		}

		if (typeof(channel) != "string" || !/[0-9]+-[0-9]+/.test(channel)) {
			self.log("Invalid channel");
			return cb && cb(new Error("Invalid channel"));
		}

		self.sendCommand("CG " + channel + " " + cmd + " 1", cb);
	}
1183449
def invite(self, channel, nick):
        
        with self.lock:
            self.is_in_channel(channel)

            self.send('INVITE %s %s' % (nick, channel))

            while self.readable():
                    msg = self._recv(expected_replies=('341', '301'))

                    if msg[0] == '341':
                        pass
                    elif msg[0] == '301':
                        away_msg = msg[2].split()[1].replace(':', '', 1)
                        return 'AWAY', away_msg
1053879
def join(channel, key = nil)
      channel = Channel(channel)
      channel.join(key)

      channel
    end
275558
def part_channel(self, channel, reason=None, tags=None):
        """"""
        params = [channel]
        if reason:
            params.append(reason)
        self.send('PART', params=params, tags=tags)